-1

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!

Muhammad Jobayer
  • 157
  • 1
  • 10

1 Answers1

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