0

I need to collect GPS data, save it to database and then send it to backend every minute. And I just want to make sure that Doze mode will not screw things up.

  1. Let's assume that I launch my foreground service and implement onLocationChanged callback there.

    Do I have to do all that (collecting/storing/sending) in a foreground service just to be sure that Doze will allow to use GPS / internet?

  2. If I want to store/send data somewhere else, e.g. in a BroadcastReceiver, how can I be sure that my BroadcastReceiver is ready to handle data and is not asleep?

  3. There's a bug in Android M, which makes foreground services affected by Doze mode: https://stackoverflow.com/a/37869501/3210556

    A possible woakaround is to launch foreground service in a separate process.

    Assuming there's a foreground service in the app, what exactly is unaffected by doze?

    • The foreground service itself?
    • The process associated with the foreground service?
    • The whole app?

Thank you.

FelisManulus
  • 440
  • 4
  • 18

1 Answers1

0

If your phone goes into Dozeeverything gets put to sleep (GPS,Alarms,Internet etc) And gets deferred to a maintenance window at some point (Depending on what version of android the user has).

If your app needs to do something at a specific time you you can request to white list your app. You can review the valid use cases for white listing here which sounds like your case could be valid

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • Foreground service is supposed to bring the app out of doze mode. The question is asking if the separate process is considered foreground or the whole app is. – rcell Aug 15 '18 at 21:45