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

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

问题描述

我在我的Android应用程序上使用广播消息(从io.socket我发送广播消息到我的活动页面)。在某些设备上,三星 SM-G950F SM-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)


推荐答案

我的app遇到了同样的问题,我所做的是使用LocalBroadcastManager而不是context 。 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天全站免登陆