Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoiding doze mode without whitelisting the app

Tags:

android

I have an app which updates the location to a web service every 10 seconds. However, on devices with API level 23 or greater, when doze mode kicks in after 15 minutes to inactivity, the network connectivity is lost, and the app becomes unable to send further location updates to my web service.

Other than whitelisting the app by asking for user permission to ignore battery optimizations, which only allows a location update once every 15 minutes, what are my other options to keep getting GPS location updates and be able to send them to my web service?

like image 608
Zishan Neno Avatar asked Jan 05 '17 06:01

Zishan Neno


People also ask

How do I stop doze mode?

Tap the Options menu button (the three dots in the upper right), then tap Battery optimization. Tap the downward-pointing arrow, then tap All apps from the menu that appears. Next, tap the PsyMate app for which you want to switch off Doze mode, and in the box that appears, tap Don't optimize.

How do I whitelist an app on Android?

Where appropriate: select Android or iOS. Select App Management. Then click on Blacklist/Whitelist, click configure and select Whitelist. Select +Add to either an app or App group.

What is doze What about app standby?

Doze mode and App Standby If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. In Doze mode, the system attempts to conserve battery by restricting apps' access to network and CPU-intensive services.


1 Answers

Though it is highly immoral to overcome doze mode, if the app can explain the issue with the battery to the user then it is better to whitelist the app.

The other option is to keep the screen on to avoid doze mode from getting triggered.

 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

This piece of code will keep the screen on. Make sure to create a black or empty layout like what battery saver in pokemon go does.

The Official Doze documentation allows whitelisting for your use case. Check it here.

like image 135
Ashik Vetrivelu Avatar answered Sep 22 '22 23:09

Ashik Vetrivelu