致命异常:android.app.RemoteServiceException:无法在 android.os.Handler.dispatchMessage 传送广播 [英] Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.os.Handler.dispatchMessage

查看:86
本文介绍了致命异常:android.app.RemoteServiceException:无法在 android.os.Handler.dispatchMessage 传送广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 android 应用程序上使用广播消息(从 io.socket 我向我的活动页面发送广播消息).在三星 SM-G950FSM-A520F 某些设备上,我收到错误致命异常:android.app.RemoteServiceException:无法传送广播".我在 Fabric crashlytics 上遇到了这个错误,我也无法重现这个问题.这是我从 Fabric 得到的日志,

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)

推荐答案

我的应用程序遇到了同样的问题,我所做的是使用 LocalBroadcastManager 而不是上下文.Android 文档还建议使用 LocalBroadcastManager 发送应用内广播接收器.

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! :)

这篇关于致命异常:android.app.RemoteServiceException:无法在 android.os.Handler.dispatchMessage 传送广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆