Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.os.Handler.dispatchMessage

14,520

Solution 1

I was facing the same issue with my app, what I do is use LocalBroadcastManager instead of context. Android documents also suggest using LocalBroadcastManager for sending in-app broadcast receivers.

//register your receiver like this
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
          new IntentFilter("custom-event-name"));

// unregister  like this
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);

// broadcastlike this
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

Hope this will help. Thanks! :)

Solution 2

I experienced the exact same thing, around the exact same time, with the same devices. The problem was ultimately related to the app I'm supporting, but I think Samsung pushed out some type of update that started triggering the problem. Before the latter part of Oct, the app never had this issue. It was driving me nuts because I couldn't figure out which broadcast was triggering the problem.

Based on user feedback, I finally narrowed it down and made the following changes:

1) I went through the app and made sure that all custom "action" strings used for Intents included the app's package name.

2) I switched from using Context::sendBroadcast() to LocalBroadcastManager::sendBroadcast().

You can see my full answer on a different post here

Share:
14,520
SHIDHIN.T.S
Author by

SHIDHIN.T.S

Here is my Other Blogs About Android Development. Please Read and Share it.

Updated on June 17, 2022

Comments

  • SHIDHIN.T.S
    SHIDHIN.T.S almost 2 years

    I am using broadcast messages on my android application (From io.socket I am sending broadcast messages to my Activity page). On some devices Samsung SM-G950F and SM-A520F I got an error "Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast". I got this error on Fabric crashlytics also I was not able to reproduce this issue. Here is the log I got from Fabric,

       Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6776)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)