Detect Changing Battery state at every percentage in android

半城伤御伤魂 提交于 2019-11-28 09:28:47

First, you do not need the BATTERY_STATS permission.

Second, the very first line of your onReceive() unregisters your BroadcastReceiver, thereby preventing you from getting any further updates.

Third, there is no guarantee that you will have battery information delivered to you for each and every 1% change. Many Motorola phones, for example, only send ACTION_BATTERY_CHANGED every 10% until the battery gets low. The decision on how frequently to broadcast ACTION_BATTERY_CHANGED is up to the device manufacturer, not you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!