Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create "Battery usage" intent android

On my nexus one, there is a handy app reachable from Settings > About Phone > Battery use.

I'd like to StartActivity() that app from one of my Activities.

I can see in the log that when Settings runs it, this intent is logged:

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

I'm having trouble relating that to something in Android Java source. I can't even find "fuelgauge" in the GIT source. Can anyone point me to the right file, or anything else helpful, like how to create the right kind of Intent?

Thanks

Peter

like image 830
Peter vdL Avatar asked Sep 09 '10 00:09

Peter vdL


People also ask

What is Batterystats?

Batterystats is a tool included in the Android framework that collects battery data on your device. You can use adb to dump the collected battery data to your development machine and create a report you can analyze using Battery Historian.

What is intent setType in android?

setType(String mimeType) input param is represent the MIME type data that u want to get in return from firing intent(here myIntent instance). by using one of following MIME type you can force user to pick option which you desire. Please take a Note here, All MIME types in android are in lowercase.

Does leaving location on drain battery?

Apps like Waze™ and Google Maps™ help you get around using your phone's location services feature. But if these apps are running behind the scenes and you aren't traveling, location services can drain your battery.


1 Answers

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);
}
like image 88
Chris Lacy Avatar answered Oct 02 '22 19:10

Chris Lacy