Android programmatically get battery usage per application

我的未来我决定 提交于 2019-12-08 19:44:15

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/23311058/android-programmatically-get-battery-usage-per-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!