How to open Battery Use in About Device part of Se

2019-02-25 02:17发布

问题:

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);
}