6

I have created the application for getting the Users latlong and send them to the server. So, now we have created the Foreground services for the getting the USER's location and is working fine in the All the other devices including the Android OS 9.0.

But in the specific OnePlus 5T Android 9.0 device the foreground service stops working when the device is locked and Service is also terminated after one hour, also even after we have disabled the deep cleaning option there.

Please let us know if there is something with the Device specific config that we need to change for working foreground service continuously.

Kishan sharma
  • 701
  • 1
  • 6
  • 20
  • 1
    I am also having exact same issue. Doesn't work for One plus, but , work in other devices. if any one found solutions, please suggest. – Topsy Feb 08 '19 at 06:14
  • see if this helps https://stackoverflow.com/questions/54399485/is-there-any-way-to-run-service-continuously-in-android , not much releated – Manohar Feb 08 '19 at 06:42
  • If the Device have a "Deep clean" feature (like what I see on chinese Blackview devices), then it should be an option to put an App in its whitelist. I don't think a manufacturer can obey an use to force-kill all Apps when the screen goes off, so it should be a way to disable this behavior per-App or at least per-System scope. – emandt Feb 08 '19 at 07:13

1 Answers1

2

Reason behind that- Alarm manager is not calling on time even if you are using setAndAllowWhileIdle() or setExactAndAllowWhileIdle() it won't work and pending intent also get destroy, Only High priorities task get executed in system like FCM push notification.

So the solution I found is :- implement push notification in your android application and send data message through push notification and start service from

public void onMessageReceived(RemoteMessage remoteMessage) { 
          //start your service from this method
}

note :- Check your Force Stop button of that application is enable or disable if its disabled that means system complete killed your application

Android doze-standby mode and idle mode

Nikunj
  • 3,937
  • 19
  • 33
Ronil Raut
  • 133
  • 9