Build Battery Use Android App

In my basic connection, there is a convenient application accessible from Settings> About Phone> Battery Usage.

I would like the StartActivity () application to use one of my actions.

I see in the log that when the settings start, this intention is logged:

Starting activity: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.fuelgauge.PowerUsageSummary } 

I am having problems with this, something in the Android Java source. I can’t even find “fuel gas” in the GIT source. Can someone point me to the correct file or anything else useful, for example, how to create the correct type of intention?

thanks

Peter

+7
android android-intent battery
source share
2 answers

The code is as follows:

 Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0); // check that the Battery app exists on this device if(resolveInfo != null){ startActivity(powerUsageIntent); } 
+18
source share

Based on the small @Chris Lacy code, I wrapped the code in a static method that you call to open this screen:

 public static void openBatteryUsagePage(Context ctx){ Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); ResolveInfo resolveInfo = ctx.getPackageManager().resolveActivity(powerUsageIntent, 0); // check that the Battery app exists on this device if(resolveInfo != null){ ctx.startActivity(powerUsageIntent); } else Toast.makeText(ctx, R.string.not_found, Toast.LENGTH_LONG).show(); } 
0
source share

All Articles