Android M startActivity battery optimization

前端 未结 3 826
北荒
北荒 2021-02-08 17:30

I\'m developing an app that should alert an user if is near a place. and of course have to do that also if the phone is in idle. With DOZE now I understood that I have to whitel

3条回答
  •  旧时难觅i
    2021-02-08 17:41

    Try the below code to open Ignore Battery Optimization Settings page.

    private void openPowerSettings() {
        startActivityForResult(new Intent(android.provider.Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), 0);
    }
    

    No extra permissions are required to be added to the manifest file.

提交回复
热议问题