Skip to content Skip to sidebar Skip to footer

How To Schedule My Android App To Do Something Every Hour

I want my app to access database every hour and read next record from the table then update desctop widget and send notification. I know that there is AlarmManager which I can use

Solution 1:

take a look at the demo applications provided with android sdk

http://developer.android.com/samples/RepeatingAlarm/index.html

the look at AlarmService_Service for the implementation of the service once the alarm has been triggered


Solution 2:

put all of the background tasks you want to do in your app in Services which perform tasks in the background. In the service you should be able to define a timer that causes whatever updates you want to occur every x hours.

In the onCreate() of the widget, start the service. onCreate() is called every time that the widget comes to life (such as when the phone starts if it is on the home screen) and will therefore guarantee that the Service is always running.

Hope this was helpful.


Solution 3:

Just for the sake of completness, I am linking here the official docs, where the issue of the rebooting is adressed.

http://developer.android.com/training/scheduling/alarms.html#boot


Post a Comment for "How To Schedule My Android App To Do Something Every Hour"