How to open Battery Use in About Device part of Se

2019-02-25 02:15发布

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!

2条回答
ゆ 、 Hurt°
2楼-- · 2019-02-25 02:24

Try this..

Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);             
if(resolveInfo != null){
         startActivity(powerUsageIntent);
}
查看更多
太酷不给撩
3楼-- · 2019-02-25 02:43
Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);        
startActivity(intentBatteryUsage);
查看更多
登录 后发表回答