How do I make my android app appear in Ultra Power Saving Mode

abel picture abel · Aug 22, 2016 · Viewed 9.7k times · Source

Some samsung devices have an Ultra Power Saving Mode which turns off wifi, turns the screen grayscale and limits usage to a few basic apps.

It however does allow you to add some apps which can then be used. These apps include Facebook and WhatsApp. How do I make my app appear in this list? What changes do I have to make to the app so that it may appear on this list? Or is this list based on a white list maintained by Samsung?

Answer

user3956566 picture user3956566 · Sep 10, 2017

It may be possible using the permission REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. This permission does not require explicit user permission. So will be granted. Although this will not prevent a user manually stopping the application.

From the docs:

This is a normal permission: an app requesting it will always be granted the permission, without the user needing to approve or see it.

ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS will put the app onto the device's whitelist.

isIgnoringBatteryOptimizations will let you know if the app is whitelisted.

some notes from the docs:

Note: most applications should not use this; there are many facilities provided by the platform for applications to operate correctly in the various power saving modes. This is only for unusual applications that need to deeply control their own execution, at the potential expense of the user's battery life. Note that these applications greatly run the risk of showing to the user as high power consumers on their device.

Input: The Intent's data URI must specify the application package name to be shown, with the "package" scheme. That is "package:com.my.app".

It's not something I'd recommend abusing.

There is a list of Acceptable Use Cases for Whitelisting.

In general, your app should not be on the whitelist unless Doze or App Standby break the core function of the app or there is a technical reason why your app cannot use FCM high-priority messages.

Thanks to adsamcik for this latest link.