How to open Manage apps battery usage settings in MIUI devices

2.4k views Asked by At

How to open Manage apps battery usage settings in MIUI devices programmatically?

I open the settings by this:

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

But I don't know how to open Manage apps battery usage settings in MIUI devices.

1

There are 1 answers

0
Rahul Khurana On

You can try few methods below:

Personally i don't have 5.1 devices but tried it over simulator

    Intent batterySaver = new Intent();
    battSaverIntent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$BatterySaverSettingsActivity"));
    startActivityForResult(batterySaver, 0);

or for summary usage

Intent batterySaver = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
startActivity(batterySaver);

Documentation link here

For API level >22

startActivityForResult(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS), 0);