如何在 android L 中打开省电模式 activity

How to open Battery saver activity in android L

在 android 的 Lollipop 版本中,我们在设置->电池->(在操作溢出中)省电模式 activity 中有省电模式 activity。我想以编程方式打开此 activity。我必须使用哪个意图?

提前致谢!!!

尝试以下意图:

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

或者

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

打开下面的文档linkhere

使用 documented action string:

startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS))

请注意,此操作字符串是 API 级别 22 的新功能。欢迎您尝试在旧设备上使用它,但不太可能会有 activity 支持它.