Anyway to detect if Broadcast Receiver is registered?

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


Sponsored Links
 Hi,

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
registered.

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

Sam

--



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

Hi,

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

Addition/modification of the string values.

Br,
Vikram
--~--~---------~--~----~------------~-------~--~----~

2. How to import com.android.internal.telephony.Phone?

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
errors:

code:
import com.android.internal.telephony.Phone
import com.android.internal.telephony.PhoneFactory
...
PhoneFactory.makeDefaultPhones(this)
Phone phone = PhoneFactory.getDefaultPhone()

error:
The com.android.internal.telephony.Phone can not be resolved.
The com.android.internal.telephony.PhoneFactory 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?
Thanks.
Nio
--~--~---------~--~----~------------~-------~--~----~

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.