I am writing a little Android app that will send alarms to the user based on certain rules. For this there are certain things that I need:
- I want to have something that will run periodically and check my DB to see if there are any alarms I should send to the user.
- I want this to run even if my app is closed or the phone is asleep
- I want this to start automatically every time the phone is turned on
I did a little research and these are the pieces we need:
- Services – To have our app do something in the background
- AlarmManager – To schedule the service to be executed in the future
- ACTION_BOOT_COMPLETED – This is a broadcast intent that Android sends when it boots
Now, lets start putting things together.