I'm working on real-time location tracking app and updating current location to the server via using foreground service.
Now i'm able to keep app active while device in deep sleep. But due to Network access is suspended on Doze mode, i can't able to update it on server.
As per google developer guide suggestion we can solve this issue by using high-priority FCM messages.
But in my case how to notify server for push notification while Network access is suspended (need to identify internet access disable either by OS or manually).
Network access is disabled in doze mode, regardless if your application is ignoring battery optimizations. The only way to wake-up your device from doze mode and to get network access is by sending a high priority Google Cloud Message to your application.
Doze simply keeps your phone from burning through the battery while it's asleep on a desk or table or something. An app that goes into Standby loses all network access and all its background sync jobs are suspended.
One way is register for action-
"android.os.action.DEVICE_IDLE_MODE_CHANGED"
this will broadcast once the device modes will change and then figure out device is in doze/non-doze using :
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
boolean isDeviceIdle = pm.isDeviceIdleMode();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With