Service needs to run Continuously when device is locked/enter into Doze Mode

328 views Asked by At

My App needs to run in background continuously to send the location updates to the server. I tried Timer , Job Scheduler with background service none of these didn't worked. Its working fine when device is active, after entering into Doze mode the timer which i used is getting paused. When the device is active the Timer is getting resumed.

Checked with this Permission also ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS.

1

There are 1 answers

2
Narendra_Nath On

Post OREO there are limits to what you can do on a background thread

Create a foreground service. In which you will put notification for the user while your service is running.

Here is a StackOverflow answer which would help you create that foreground service Foreground Service