android.app.RemoteServiceException: can‘t deliver broadcast

Daily error record

android.app.RemoteServiceException: can't deliver broadcast 

W BroadcastQueue: Can't deliver broadcast to com.broadcast.test(pid 1769). Crashing it.
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.broadcast.test, PID: 1769
E AndroidRuntime:
android.app.RemoteServiceException: can't deliver broadcast
E AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
E AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:106)
E AndroidRuntime:     at android.os.Looper.loop(Looper.java:164)
E AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:6494)
E AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

(上面是系统的日志,下面一句是我对crash的捕捉日志)

E CrashHandler: ex = android.app.RemoteServiceException: can't deliver broadcast

I was surprised when I first received the exception report because the app had been running normally for 2 months. The sudden error is still very confusing. But as a R&D, errors are definitely caused by code running, no matter how many reasons there are, whether it is caused by code logic or not. We all must find the reasons and resolve the doubts in our hearts. Not much to say, just read the log, break points, and follow step by step.

Finally, it was found that the problem was caused by using broadcast to transmit data across processes. Use broadcast to transmit intent data. Since the data encapsulated by the intent comes from the back-end network, the network data suddenly becomes larger and exceeds the transmission size limit of the intent, causing the application to crash.

According to saving data to a file during debugging, the test equipment gets stuck after transmitting about 200k of data.

Solution: Use other methods to transmit large data.

1. Use global variable cache. Broadcast only serves as a notification, telling the recipient to update the data.

2. SharedPreference storage.

3. File storage.

Guess you like

Origin blog.csdn.net/weixin_42602900/article/details/133749145