Broadcast receiver - monitoring the Battery Level and Charging State

前端 未结 7 2132
逝去的感伤
逝去的感伤 2020-12-31 23:40

I am trying to make two toasts: one when the device is charging, and one when it`s not. But the receiver acting crazy, sending many toasts, and crashing the app. I can not f

7条回答
  •  既然无缘
    2020-12-31 23:51

    The same thing happened to me once and I received the broadcast several times.
    This sometimes happens if we register the same broadcast several times and we do not free it by re-registering it.
    Make sure you don't call twice to register the broadcast.

提交回复
热议问题