Reputation: 281
I've an android service running, but I want to execute a specific service method every X hours to update data. What's the best aproach to do this without wasting android resources?
Upvotes: 7
Views: 4599
Reputation: 33910
Look into the AlarmManager.
Clarification: since you want the service method to run with hourly intervals, you do not want to keep your service process running all this time. By using the AlarmManager
, the OS can kill the service when it is not needed, and then bring it up to execute the method when it is time.
Upvotes: 8