Suppose, I want to do something after every 4 hours of a day and I want to keep it running whilst my app isn't uninstalled. How can I do it programmatically in android? Please help!
Asked
Active
Viewed 113 times
-1
-
use alarm manager for this purpose. – Sagar Nayak Apr 13 '16 at 05:59
1 Answers
0
You'll want to use a combination of Android's AlarmManager Class and a Service. Basically you should set a repeating or inexactRepeating alarm that runs your service every four hours. Also, don't forget to set a Broadcast Receiver up for when the user shuts off their phone. If you don't, all of your services will be cancelled.

bfergs
- 39
- 4