I have written an app (AutoWifiSwitch) and one of the features I plan to add is automatically disabling the wifi scanning service in my app if power saving mode is enabled.
I know Android L is supposed to have Battery Saving implemented (previously HTC and Samsung would add the features themselves to the software). Presumably this now means Google will have added some sort of API for it. Ideally there would be a new action added so I could listen for that.
I would also like to know if the above is possible with HTC/Samsung APIs and if so, how do I use them.
I've been searching everywhere for the above questions but had absolutely no luck, the app SecureSettings (an addon for Tasker) is able to hook into the HTC/Samsung APIs to enable the power saver anyway, I'm not quite sure how they do it.
Edit: The power saver value can be gotten from the PowerManager in Android L, not sure if there is an Action for it though.
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
boolean powerSaveMode = powerManager.isPowerSaveMode();
Docs: developer.android.com/.../PowerManager#isPowerSaveMode()
Added in API level 21
(Android 5.0)
It did not work for me on my Samsung S8, Android 9, instead I used:
$adb shell settings put global low_power 1
$adb shell settings get global low_power
...and it worked!
Translating it into java it goes something like this:
final String result = Settings.Global.getString(getContentResolver(),"low_power");
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