Receiver not registered exception error?

后端 未结 10 2248
醉酒成梦
醉酒成梦 2020-11-28 05:41

In my developer console people keep reporting an error that I cannot reproduce on any phone I have. One person left a message saying he gets it when they try to open the set

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 06:17

    The root of your problem is located here:

     unregisterReceiver(batteryNotifyReceiver);
    

    If the receiver was already unregistered (probably in the code that you didn't include in this post) or was not registered, then call to unregisterReceiver throws IllegalArgumentException. In your case you need to just put special try/catch for this exception and ignore it (assuming you can't or don't want to control number of times you call unregisterReceiver on the same recevier).

提交回复
热议问题