获取剩余电池时间可从Android手机 [英] Get the remaining battery time available from an Android phone
问题描述
是否有可能获得剩余的电池时间可从Android手机?
Is it possible to get the remaining battery time available from an Android phone?
感谢。
推荐答案
您可以通过注册一个接收器,用于操作的 Intent.ACTION_BATTERY_CHANGED 获取的电池寿命与广播接收器的帮助。我的答案是唯一的关键,获得Android开发者网站上的信息。
You can get battery life with help of broadcast receiver by registering a receiver for action Intent.ACTION_BATTERY_CHANGED. My answer is key only, get information from Android Developers website.
通过使用下面的语句中的onReceive(BroadcastReceiver的的)方法与上述意图的动作,你会得到现有的电池电量(如50%,60%等)。但你不能估计剩余的时间,因为一些应用程序可能会消耗更多的功率。所以,我认为电池电量,以剩余时间转换将不会给出正确的结果。
By using the below statement in onReceive() method of BroadcastReceiver with above Intent action, you will get battery level currently available(e.g., 50%, 60%, etc.). But you can't estimate the time remaining, because some apps may consume more power. So i think battery level to time remaining conversion won't give correct result.
battery_level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
我希望这可以帮助你。
I hope it may help you.
这篇关于获取剩余电池时间可从Android手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!