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

2

5

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!

Carpophore answered 15/11, 2013 at 11:16 Comment(0)
D
18
Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);        
startActivity(intentBatteryUsage);
Dysphagia answered 15/11, 2013 at 11:17 Comment(0)
B
2

Try this..

Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);             
if(resolveInfo != null){
         startActivity(powerUsageIntent);
}
Bloodstain answered 15/11, 2013 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.