Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Battery saver activity in android L

In Lollipop version of android we have Battery saver activity in Settings->Battery->(in action overflow)Battery saver activity. I want to open this activity programatically. Which intent I have to use?

Thanks in advance!!!

like image 367
Chandrakanth Avatar asked Oct 22 '25 13:10

Chandrakanth


2 Answers

try the following intent:

Intent batterySaverIntent=new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS);
startActivity(batterySaverIntent);

Or

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

for documentation open the following link here

like image 159
No Name Avatar answered Oct 25 '25 04:10

No Name


Use the documented action string:

startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS))

Note that this action string is new to API Level 22. You are welcome to try using it on older devices, but it is less likely that there will be an activity that supports it.

like image 37
CommonsWare Avatar answered Oct 25 '25 03:10

CommonsWare