I can't receive broadcast on battery state change?

前端 未结 3 1452
野趣味
野趣味 2020-12-06 17:07

I am having the exact same problem as this post: Battery broadcast receiver doesn't work. But it seems no one has answered that question.

Here is my BroadcastRec

3条回答
  •  时光取名叫无心
    2020-12-06 17:29

    Make sure you have the battery receiver class not as a subclass of another one but as a seperate class in your project.

    Also try using Context.registerReceiver() method explicitly in your code and do not forget to unregister it: http://developer.android.com/reference/android/content/Context.html#registerReceiver%28android.content.BroadcastReceiver,%20android.content.IntentFilter%29

提交回复
热议问题