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 aBroadcastReceiverimplementation that callsContext#unregisterReceiver(BroadcastReceiver)passing itself as the arg 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 anIllegalArgumentExceptionbeing 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.
There is no API function to check if a receiver is registered. The workaround is to put your code in a try {...} catch(IllegalArgumentException e) {...} block.