由网友(越贱越快乐)分享简介:有没有一种简单的方法,当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.
相关推荐
最新文章