如何检测电源连接状态?电源、状态

由网友(越贱越快乐)分享简介:有没有一种简单的方法,当USB或AC电源连接到Android手机得到通知?Is there an easy way to be notified when USB or AC power is connected to an Android phone?推荐答案设置的BroadcastReceiver 为 ACT...

有没有一种简单的方法,当USB或AC电源连接到Android手机得到通知?

Is there an easy way to be notified when USB or AC power is connected to an Android phone?

推荐答案

设置的BroadcastReceiver ACTION_BATTERY_CHANGED 。一个意图额外的会告诉你什么样的充电状态 - 见 BatteryManager 详细信息

Set up a BroadcastReceiver for ACTION_BATTERY_CHANGED. An Intent extra will tell you what the charging state is -- see BatteryManager for details.

阅读全文

相关推荐

最新文章