I’m using Context.sendOrderedBroadcast method to send a broadcast and check if anyone has received it before getting to the resultReceiver.
Here’s a code snippet :
context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Do something if this broadcast was not handled by others.
}, null, Activity.RESULT_OK, null, null);
This usually works with no problem but from time to time I get the following error and my BroadcastReceiver is not called :
W/ActivityManager(12067): Failure sending broadcast result
of Intent { act=… }
W/ActivityManager(12067): android.os.DeadObjectException
W/ActivityManager(12067): at
android.os.BinderProxy.transact(Native Method)
W/ActivityManager(12067): at
android.content.IIntentReceiver$Stub$Proxy.performReceive(IIntentReceiver.java:121)
W/ActivityManager(12067): at
com.android.server.am.ActivityManagerService.performReceive(ActivityManagerService.java:12912)
W/ActivityManager(12067): at
com.android.server.am.ActivityManagerService.processNextBroadcast(ActivityManagerService.java:13133)W/ActivityManager(12067): at
com.android.server.am.ActivityManagerService.finishReceiver(ActivityManagerService.java:12766)
W/ActivityManager(12067): at
android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:287)
W/ActivityManager(12067): at
com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1755)
W/ActivityManager(12067): at
android.os.Binder.execTransact(Binder.java:301)
W/ActivityManager(12067): at
dalvik.system.NativeStart.run(Native Method)
So far I only encountered it on Motorola Defy phones with Android version 2.1, but it might happen to others as well.
I could not find any reference to it on the internet, does anyone know why this happens?
Thanks!
I can see this happening if the component that called
sendOrderedBroadcast()was destroyed prior to the broadcast winding its way back to the supplied instance of theBroadcastReceiveranonymous subclass.