Android programmatically get battery usage per application

User10001 picture User10001 · Apr 26, 2014 · Viewed 8.1k times · Source

android how to get battery usage per application. i have seen the applications that provides the battery used per application, but i do not find the api for this.reference link for the application application that perform the same

Answer

Sunil kumar picture Sunil kumar · May 11, 2015

In the system level its showing some required information to get per application power consumption(Power Profiling) when we run the command "adb shell dumpsys batterystats"

And the output is given below which was redirected to a output file.We can parse it and use the below part from one Java application which can be run in outside of Android.

Device battery use since last full charge Amount discharged (lower bound): 63 Amount discharged (upper bound): 69 Amount discharged while screen on: 38 Amount discharged while screen off: 31

Estimated power use (mAh): Capacity: 2300, Computed drain: 1007, actual drain: 1449-1587 Unaccounted: 442 Screen: 398 Phone calls: 108 Uid 1000: 97.0 Wifi: 75.4 Idle: 61.6 Uid 0: 57.6 Uid u0a157: 32.1 Cell standby: 29.7 Uid u0a163: 21.8 Uid u0a8: 20.1 Uid 1013: 14.7 Uid u0a10: 13.2 Uid u0a22: 12.6 Uid u0a70: 11.5 Uid u0a99: 10.1 Uid u0a4: 9.40 Uid u0a20: 7.92 Uid u0a93: 5.49 Uid 1001: 5.47 Uid u0a92: 5.35 Uid u0a94: 2.27 Uid u0a16: 2.22 Uid u0a56: 0.713 Uid u0a67: 0.675 Uid u0a165: 0.670 Uid u0a34: 0.589

Yes, here the question remain unanswered how can we do it from one android application.

Battery Stats Output Logs