Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android L中打开电池节省器活动_Android_Android Intent_Android 5.0 Lollipop - Fatal编程技术网

如何在android L中打开电池节省器活动

如何在android L中打开电池节省器活动,android,android-intent,android-5.0-lollipop,Android,Android Intent,Android 5.0 Lollipop,在棒棒糖版本的android中,我们在“设置->电池->(运行中溢出)”电池节电器活动中设置了电池节电器活动。我想按程序打开此活动。我必须使用哪种意图 提前感谢 尝试以下意图: Intent batterySaverIntent=new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS); startActivity(batterySaverIntent); 或 有关文档,请打开以下链接,使用: 请注意,此操作字符串对于API级别22是新的。欢迎您尝试

在棒棒糖版本的android中,我们在“设置->电池->(运行中溢出)”电池节电器活动中设置了电池节电器活动。我想按程序打开此活动。我必须使用哪种意图


提前感谢

尝试以下意图:

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

有关文档,请打开以下链接,使用:


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

是否可以通过编程方式知道为此设置了什么类型的设置?@SabidHabib文档提到“在某些情况下,可能不存在匹配的活动,因此请确保您对此进行防护。”
Intent battSaverIntent = new Intent();
battSaverIntent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$BatterySaverSettingsActivity"));
startActivityForResult(battSaverIntent, 0);
startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS))