Android 安卓应用耗电
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12581333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android App power consumption
提问by user1696978
How to check the power consumption in each applications in Android?
At least the power consumption should be relative when compared with different applications and these applications might be using any of the services like WIFI,GPS,LCD,wakelock, etc.
如何检查Android中每个应用程序的功耗?
与不同的应用程序相比,至少功耗应该是相对的,这些应用程序可能正在使用任何服务,如 WIFI、GPS、LCD、唤醒锁等。
Are there any APIs in android regarding the same in order to measure the power consumption for the applications using the above resources?
android 中是否有任何与此相关的 API 以测量使用上述资源的应用程序的功耗?
回答by Yury
There is a research papercalled “Accurate Online Power Estimation and Automatic Battery Behavior Based Power Model Generation for Smartphones”. For this paper the researchers developed a tool called PowerTutor, the sources of which you can find here. It should be mentioned that your device has to be rooted to use this application.
有一篇名为“Accurate Online Power Estimation and Automatic Battery Behavior Based Power Model Generation for Smartphones”的研究论文。对于这篇论文,研究人员开发了一个名为 PowerTutor 的工具,您可以在此处找到其来源。应该提到的是,您的设备必须植根才能使用此应用程序。
回答by ishan
Check out Powertutor. It is in my experience the best application out there to measure application wise power consumption. It is not 100% accurate but is good enough for estimations.
查看Powertutor。根据我的经验,它是衡量应用程序功耗的最佳应用程序。它不是 100% 准确,但足以进行估计。
回答by AlexA
You cannot programatically check the battery consumption for each application. Instead you can check the overall consumption like this:
您无法以编程方式检查每个应用程序的电池消耗。相反,您可以像这样检查整体消耗:
energyLeftInmAh = device battery capacity in mAh * battery level in % * 0.01;
energyLeftInmAh = 设备电池容量 mAh * 电池电量 % * 0.01;
E.g Nexus 5, battery capacity: 2300 mAh
例如 Nexus 5,电池容量:2300 mAh
mBatteryManager = (BatteryManager)MainActivity.this.getSystemService(Context.BATTERY_SERVICE);
int level = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
double mAh = (2300 * level * 0.01);
回答by Kumar Rangarajan
(disclaimer: I co-founded the company which built the below mentioned product)
(免责声明:我共同创立了制造以下提到的产品的公司)
Try Little Eyefrom Little Eye Labs, that does exactly this. One can track an individual app's power and get the breakdown by CPU/display & Wifi (the upcoming version will support GPS and 3G). It also goes beyond power and tracks data, memory and CPU consumption of an individual app. Note its a desktop tool that you need to download and install from here.
试试Little EyeLabs 的 Little Eye,它就是这样做的。可以跟踪单个应用程序的功率并通过 CPU/显示器和 Wifi 获取故障(即将推出的版本将支持 GPS 和 3G)。它还超越了功耗,可以跟踪单个应用程序的数据、内存和 CPU 消耗。注意它是一个桌面工具,您需要从这里下载和安装。
Hope this helps.
希望这可以帮助。
回答by Xudong Ran
First, the powertutor from Google Play is out of date. I've checked the source code of it, and find that the power estimation model is for some old mobile models. The value from power tutor is way smaller than the actual power consumption.
首先,来自 Google Play 的 powertutor 已经过时了。我查看了它的源代码,发现功耗估计模型是针对一些旧的移动模型的。Power Tutor 提供的值远小于实际功耗。
Therefore, I would recommend you to use Battery Historianwhich is developed by google used to estimate battery consumption of each App. But it's written in Python/Go. It will illustrate the hardware invocation in a html file. And you can find battery consumption of each App in a corresponding text file.
因此,我建议您使用由谷歌开发的Battery Historian,用于估算每个 App 的电池消耗。但它是用 Python/Go 编写的。它将在 html 文件中说明硬件调用。您可以在相应的文本文件中找到每个 App 的电池消耗情况。
回答by Royston Pinto
One easy guide to see which is consuming how much battery from ICS onwards is to check Settings->Battery. Here it shows the % consumed by the app. Other ways could be to physically monitor battery drop by using the app intensively, for e.g. battery may be 80% before u start using the app. Then you try for 30 minutes and then check battery % again.
查看从 ICS 开始消耗多少电池的一个简单指南是检查设置->电池。这里显示了应用程序消耗的百分比。其他方法可能是通过集中使用该应用程序来物理监控电池电量下降,例如,在您开始使用该应用程序之前,电池电量可能为 80%。然后您尝试 30 分钟,然后再次检查电池百分比。