I need to check if my registered receiver is still registered if not how do i check it any methods?
I am not sure the API provides directly an API, if you consider this thread:
I was wondering the same thing.
In my case I have aBroadcastReceiver
implementation that callsContext#unregisterReceiver(BroadcastReceiver)
passing itself as the argument after handling the Intent that it receives.
There is a small chance that the receiver'sonReceive(Context, Intent)
method is called more than once, since it is registered with multipleIntentFilters
, creating the potential for anIllegalArgumentException
being thrown fromContext#unregisterReceiver(BroadcastReceiver)
.In my case, I can store a private synchronized member to check before calling
Context#unregisterReceiver(BroadcastReceiver)
, but it would be much cleaner if the API provided a check method.