Skip to content Skip to sidebar Skip to footer

Estimating Time Until Battery Is Depleted For Android Phones Programmatically

So there are ways to get the current battery levels via a listener. However, these give you the values of the phone's current battery state, but no indicator of how fast/slow is th

Solution 1:

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.

Post a Comment for "Estimating Time Until Battery Is Depleted For Android Phones Programmatically"