估计时间,直到电池耗尽Android手机编程 [英] Estimating time until battery is depleted for Android phones programmatically

查看:102
本文介绍了估计时间,直到电池耗尽Android手机编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,有办法通过监听来获取当前电池电量。然而,这些给你手机的当前电池状态的值,但不知道如何快速的指示/慢是其电池耗尽的速度。

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 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?

非常感谢。

推荐答案

如果您跟踪一段时间内,或许每隔几秒钟,那么你可以跟踪,然后你就可以推断,因为你可以保持或许100在一个圆阵值,然后自顾自地取平均值,然后从那里你可以得到两个数字,一个是平均在这个周期较长,这甚至可能出尖峰,但如果秒杀是新的常态,那么也许使用10值也算。

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.

这篇关于估计时间,直到电池耗尽Android手机编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆