SHI*_*T.S 18 java android broadcastreceiver android-broadcast android-broadcastreceiver
我在我的Android应用程序上使用广播消息(从io.socket我发送广播消息到我的活动页面).在某些设备上,三星SM-G950F和SM-A520F出现错误" Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast".我在Fabric crashlytics上遇到此错误,但我无法重现此问题.这是我从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)
Run Code Online (Sandbox Code Playgroud)
我的应用程序遇到了同样的问题,我所做的是使用LocalBroadcastManager而不是上下文.Android文档还建议使用LocalBroadcastManager发送应用内广播接收器.
//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);
Run Code Online (Sandbox Code Playgroud)
希望这会有所帮助.谢谢!:)
小智 5
我在几乎同一时间、使用相同的设备经历了完全相同的事情。该问题最终与我支持的应用程序有关,但我认为三星推出了某种类型的更新,开始触发该问题。10月下旬之前,该应用从未出现过此问题。这让我抓狂,因为我无法弄清楚哪个广播触发了问题。
根据用户的反馈,我最终缩小了范围并做了以下更改:
1)我检查了应用程序并确保用于意图的所有自定义“操作”字符串都包含应用程序的包名称。
2)我从使用 Context::sendBroadcast() 切换到 LocalBroadcastManager::sendBroadcast()。
| 归档时间: |
|
| 查看次数: |
7729 次 |
| 最近记录: |