Skip to content Skip to sidebar Skip to footer

Alarmmanager Does Not Fire Service After More Than 1 Hour - Or When The App Is In Doze... - Android Oreo

I try to set up an alarm with Alarmmanager and fire a service five times. I try to fire it after 30 minutes after the time is set. After 1 hour, after 2 hours, 3 hours and 5 hours

Solution 1:

There are changes in oreo to improse battery etc. that limits your usage of background services. (Look at this)

You can use a foreground service instead (with an ongoing notification) You have to call startForegroundService() instead of startService() and call startForeground(ID, YOUR_NOTIFICATION) in the five seconds after the service is launched

Or you can use the JobScheduler (how to use it) that fire if some conditions are met (i.e. if you are connected to internet, if your device is charging, if your connection is unmetered, etc)

Good luck

Solution 2:

You would not be able to run background services long running in Oreo as there are behaviour changes, now Oreo to optimise system memory, battery etc, it kills background service, to solve your issue you should use foreground service.

Also please have a look at: https://stackoverflow.com/a/50639788/5479863

Post a Comment for "Alarmmanager Does Not Fire Service After More Than 1 Hour - Or When The App Is In Doze... - Android Oreo"