如何读取电池电量?
如上所述,我想获得电池充电的总数。 我已经使用的电池意图仅显示电量、电压、温度......但不显示总加载周期。
as mentioned above, I want to get the total number of battery chrarges.
The batery Intent I'm already using only shows me Level, Voltage, Temperature ... but not the total loading cycles.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以注册一个 Intent 接收器来接收 ACTION_BATTERY_CHANGED 的广播: http:// developer.android.com/reference/android/content/Intent.html#ACTION_BATTERY_CHANGED。
广播操作:这是一个粘性广播,包含充电状态、电量以及有关电池的其他信息。有关 Intent 内容的文档,请参阅 BatteryManager。
您无法通过清单中声明的组件接收此信息,只能通过使用 Context.registerReceiver() 显式注册来接收。有关发送和接收的不同电池相关广播,请参阅
ACTION_BATTERY_LOW
、ACTION_BATTERY_OKAY
、ACTION_POWER_CONNECTED
和ACTION_POWER_DISCONNECTED
通过明显的接收者。这是一个受保护的意图,只能由系统发送。
常量值:“
android.intent.action.BATTERY_CHANGED
”You can register an Intent receiver to receive the broadcast for ACTION_BATTERY_CHANGED: http://developer.android.com/reference/android/content/Intent.html#ACTION_BATTERY_CHANGED.
Broadcast Action: This is a sticky broadcast containing the charging state, level, and other information about the battery. See BatteryManager for documentation on the contents of the Intent.
You can not receive this through components declared in manifests, only by explicitly registering for it with
Context.registerReceiver()
. SeeACTION_BATTERY_LOW
,ACTION_BATTERY_OKAY
,ACTION_POWER_CONNECTED
, andACTION_POWER_DISCONNECTED
for distinct battery-related broadcasts that are sent and can be received through manifest receivers.This is a protected intent that can only be sent by the system.
Constant Value: "
android.intent.action.BATTERY_CHANGED
"