Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out how much battery my Android app consumes on user's devices?

I am writing an app to evaluate the feasibility of a Bluetooth P2P network on Android.

I noticed that on a Galaxy Nexus, it uses very little battery, while on a Nexus S, it drains the battery very quickly. This is directly caused by high CPU load due to Bluetooth.

Now, I would like to collect information about how much battery drain my app causes on the devices it is installed upon. Simply logging time vs. battery level is useless since I don't know when the device is in use, and even if I logged that, I would not know if the user is playing 3D games while Torrenting over WiFi or reading an eBook on a dimmed screen.

To make the problem worse, not all battery usage caused by my app is attributed to it in the battery screen - some is listed as "Bluetooth", for example (again, device-dependent).

Is there any easy, privacy-preserving way to get useful information on non-rooted devices? The devices are not under my control. I cannot simply go look in the menu, I cannot use ADB.

like image 499
Jan Schejbal Avatar asked Apr 09 '13 11:04

Jan Schejbal


People also ask

How do I check the power consumption of an Android app?

Open your phone's Settings and tap Battery > More (three-dot menu) > Battery usage. Under the section “Battery usage since full charge,” you'll see a list of apps with percentages next to them. That's how much power they drain.

What is using my Android Battery?

In most versions of Android, hit Settings > Device > Battery or Settings > Power > Battery Use to see a list of all apps and how much battery power they're using. (In Android 9, it's Settings > Battery > More > Battery Usage.)


1 Answers

The Android API doesn't support this currently. The only available documentation is the one describing how to use BatteryManager's broadcasts, which only supply the overall battery level and no per-application details.

I suppose that even if there are undocumented ways to emulate what the System Settings battery manager shows, they would require rooting.

like image 106
Shade Avatar answered Oct 11 '22 10:10

Shade