How to open Battery Use in About Device part of Settings Programatically in android?

。_饼干妹妹 提交于 2019-12-20 02:44:11

问题


i am developing an android app where i want to open the Battery use intent which is present in About device part of settings programatically. I am using the below code for it.

                 Intent i = new Intent();
                 i.setAction(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS);
                 startActivity(i);

The above code opens the About Device intent. But i want to open the Battery use option which is inside the About device part of Settings. Not getting how to do it. Please Help! Thanks!


回答1:


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



回答2:


Try this..

Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);             
if(resolveInfo != null){
         startActivity(powerUsageIntent);
}


来源:https://stackoverflow.com/questions/19999833/how-to-open-battery-use-in-about-device-part-of-settings-programatically-in-andr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!