-4

I need to create an Android service that performs operations every 15 minutes. This service must start at boot completed and must restart automatically (in case of interruption).With Android Oreo, the startService method generates an exception and the startForegroundService method aborts the service after 5 seconds. I saw that you can use the JobScheduler, but how can I make it restart automatically in case of interruption? How can I start the Job at the boot of Android?

Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Do you really need service that will fire every 15 min? It will be very battery consuming and probably will not allow device to switch into Doze mode. So if you really care about repeating every 15 min use AlarmManager which is not being blocked by system (JobScheduler does its job only in Doze maintenance break). For more details you can refer to my answer here and only change repeat time: Scheduling a task to run every 24 hours

Domin
  • 1,075
  • 1
  • 11
  • 28