Is there any way to profile the battery usage by the application in development environment or real time? BatteryManager seems not providing any per application API
Step 1: Open the main settings area of your phone by pressing the Menu button and then choosing Settings. Step 2: Scroll down in this menu to "About phone" and press it. Step 3: On the next menu, choose "Battery use." Step 4: Look over the list of apps that are using the battery the most.
In Android Studio, launch the profiler by selecting View > Tool Windows > Profiler. button in the profiler to see the dropdown menu. Select your device, then select the application's entry under Other profileable processes. The profiler should attach to the application.
Checking Power Consumption To check the power consumption on your device, find the Android Settings menu and look for Battery. You will see a graph of power usage broken down by apps and phone functions.
I don't think that is possible at the moment.
There is a private API, PowerProfile, for retrieving battery consumption on a subsystem level (see http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/com/android/internal/os/PowerProfile.java). Also take a look at the code for the fuel gauge you find in Android's settings on how they calculate power consumption: http://google.com/codesearch/p?hl=en#ohAXAHj6Njg/src/com/android/settings/fuelgauge/PowerUsageSummary.java
There's a new tool called "little eye" that does this.
It can profile Battery, CPU, Wifi and Data usage for an App in a development environment. Its a commercial product, but in beta right now, so free to download (for the moment). (disclaimer: I work at little eye)
http://www.littleeye.co
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With