Anyway to detect if Broadcast Receiver is registered?

by Sam » Fri, 12 Mar 2010 00:24:03 GMT

Sponsored Links

I'm using more than 1 instance of MapActivity in an application that
look different from each other. I'm running into an issue sometimes
when leaving a MapActivity doesn't unregister it's BroadcastReceiver
and going Back to resume the MapActivity page it tries to re-register
the receiver again, thus receiving an Exception that Receiver already

Anyone know of a way to tell if a Broadcastreceiver is registered and
is listening?



Anyway to detect if Broadcast Receiver is registered?

by jeffkpayne » Tue, 30 Mar 2010 03:10:14 GMT

 I was wondering the same thing.  In my case I have a BroadcastReceiver
implementation that calls
Context#unregisterReceiver(BroadcastReceiver) passing itself as the
arg after handling the Intent that it receives.  There is a small
chance that the receiver's onReceive(Context, Intent) method is called
more than once, since it is registered with multiple IntentFilters,
creating the potential for an IllegalArgumentException being thrown
from Context#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.


Sponsored Links

Other Threads

1. sending and receiving LinkedHashMap through Bundle

I am having problem with getting LinkedHashMap from a Bundle. Help to solve
this issue. Sample code would be of great help.





2. No underline for texts candidates in html before committing

After digging farther, I found this is a bug of WebTextView which is
used as a "specialized version of EditText used by WebView". And it is
transparent and  only redrawing when input is password  according to

Any google UI SE can shed some light on this problem?



3. Animation support different resolution rate?

4. Weird behaviour on Nexus phone ?

5. Empty Spinner before first selection

6. Must pass Context to other classes?

7. Toggle Button state programatically