如何读取电池电量?

发布于 2024-10-11 06:31:21 字数 62 浏览 2 评论 0原文

如上所述,我想获得电池充电的总数。 我已经使用的电池意图仅显示电量、电压、温度......但不显示总加载周期。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朮生 2024-10-18 06:31:21

您可以注册一个 Intent 接收器来接收 ACTION_BATTERY_CHANGED 的广播: http:// developer.android.com/reference/android/content/Intent.html#ACTION_BATTERY_CHANGED

广播操作:这是一个粘性广播,包含充电状态、电量以及有关电池的其他信息。有关 Intent 内容的文档,请参阅 BatteryManager

您无法通过清单中声明的​​组件接收此信息,只能通过使用 Context.registerReceiver() 显式注册来接收。有关发送和接收的不同电池相关广播,请参阅 ACTION_BATTERY_LOWACTION_BATTERY_OKAYACTION_POWER_CONNECTEDACTION_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(). See ACTION_BATTERY_LOW, ACTION_BATTERY_OKAY, ACTION_POWER_CONNECTED, and ACTION_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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文