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. how to edit the resource.arsc file in the android APK package


I would like to edit the resource.arsc file with the android APK

Addition/modification of the string values.


2. How to import

Hi there,
I'm trying to invoke the functions belong to class phone and
PhoneFactory. But when I'm trying to import these packages, it reminds

Phone phone = PhoneFactory.getDefaultPhone()

The can not be resolved.
The can not be resolved.

But some other packages can be imported. I don't know why. I think all
this packages should be included in the SDK.
Can any one tell me where I am getting wrong?

3. Could not load CSS from local html file. Is functionloadDataWithBaseURL() has some problem or I need to call some other function.

4. Could title bar of activity listen to click event?

5. java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

6. How to use two different icon in two different themes

7. Question regarding adding a view that can overlap other views in the layout/activity.