Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continuously active Internet on doze mode Marshmallow and Nougat

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).

like image 850
Mukesh Kumar Avatar asked Feb 15 '17 06:02

Mukesh Kumar


People also ask

Does Internet work in doze mode?

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.

Which of these activities will occur when a device is in doze mode?

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.


1 Answers

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();
like image 177
Rupali Avatar answered Oct 06 '22 19:10

Rupali