gpt4 book ai didi

安卓电池使用情况

转载 作者:搜寻专家 更新时间:2023-11-01 08:09:53 27 4
gpt4 key购买 nike

我的目标是确定我的应用程序是否存在电池问题,因此我想添加一个模块来检查每个间隔时间我的应用程序电池使用百分比。

如何按百分比检索每个应用程序(或至少我的应用程序)的电池使用值?在stack overflow看到好几个回答都说没办法...

我能做些什么吗?即使反射(reflection)对我也有好处。

此外,是否有任何好的开发工具可以帮助我调查我的应用电池消耗情况? (按组件,即 wifi、gps、gsm 等)

谢谢

最佳答案

作者 BatteryIndicator在他的 FAQ-How_does_Battery_Indicator_work? 中写道

How does Battery Indicator work? / How does it know what percentage the battery is at?

The Android system has a mechanism where you can register your app to be notified when the battery status changes. So Battery Indicator has a background service that is technically always running but is essentially always sleeping and using basically no system resources (because it doesn't do any polling -- it just sleeps and waits to be notified by the OS when something changes), then when the battery charge (or plugged-in status) changes, the system wakes it up and tells it what the new battery charge (and status) is. Then it takes just a few milliseconds to change its icon to reflect the current charge (and status) and goes back to sleep.

If you're technically oriented, the documentation for the core API that Battery Indicator uses is here: http://developer.android.com/reference/android/os/BatteryManager.html and the actual source code to the development version of the app is here: http://code.google.com/p/battery-indicator/source/browse/trunk .

应用程序显示不同模块的消耗

 Phone in Standby 59%
Akku in Standby 39%
Display 4%

但我不知道这是如何实现的。

关于安卓电池使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10830180/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com