开发者

Estimating time until battery is depleted for Android phones programmatically

开发者 https://www.devze.com 2023-01-28 02:37 出处:网络
So there are ways to get the current battery levels via a listener. However, t开发者_StackOverflow社区hese give you the values of the phone\'s current battery state, but no indicator of how fast/slow

So there are ways to get the current battery levels via a listener. However, t开发者_StackOverflow社区hese give you the values of the phone's current battery state, but no indicator of how fast/slow is the rate at which the battery is draining.

What would be a way to estimate the time remaining until the battery is depleted? Can you do anything knowing what the voltage is? Or perhaps monitor the rate at which the battery drains over a period of time and then extrapolating it?

Many thanks.


If you keep track over a time period, perhaps every few seconds, then you can just keep track, and then you can extrapolate, as you can keep perhaps 100 values in a circular array and then just keep taking the average, then from there you can get two numbers, one is the average over this longer period, which may even out spikes, but if the spike is the new norm, then perhaps use 10 values to also calculate.

So, you have two numbers that you can show, to give the user some idea as to how much longer the battery will last, by showing some range of time left.

0

精彩评论

暂无评论...
验证码 换一张
取 消