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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With