Checking for Power Saver Mode programmatically

前端 未结 5 683
旧时难觅i
旧时难觅i 2020-12-01 21:44

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

5条回答
  •  爱一瞬间的悲伤
    2020-12-01 22:22

    It did not work for me on my Samsung S8, Android 9, instead I used:

    • to set: $adb shell settings put global low_power 1
    • to get: $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");
    

提交回复
热议问题