我正在实现简单的线程,它将消息传递给主UI线程以在UL中进行更改但有时我得到此异常并且无法弄清楚它的确切原因。
01-22 21:03:50.035: E/AndroidRuntime(18076): FATAL EXCEPTION: main
01-22 21:03:50.035: E/AndroidRuntime(18076): java.lang.RuntimeException: Main thread loop unexpectedly exited
01-22 21:03:50.035: E/AndroidRuntime(18076): at android.app.ActivityThread.main(ActivityThread.java:4426)
01-22 21:03:50.035: E/AndroidRuntime(18076): at java.lang.reflect.Method.invokeNative(Native Method)
01-22 21:03:50.035: E/AndroidRuntime(18076): at java.lang.reflect.Method.invoke(Method.java:511)
01-22 21:03:50.035: E/AndroidRuntime(18076): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-22 21:03:50.035: E/AndroidRuntime(18076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-22 21:03:50.035: E/AndroidRuntime(18076): at dalvik.system.NativeStart.main(Native Method)
01-22 21:03:50.109: E/JavaBinder(18076): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
01-22 21:03:50.109: E/JavaBinder(18076): android.util.AndroidRuntimeException: { what=102 when=-14h26m28s942ms obj=android.os.BinderProxy@41347e18 } This message is already in use.
01-22 21:03:50.109: E/JavaBinder(18076): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:187)
01-22 21:03:50.109: E/JavaBinder(18076): at android.os.Handler.sendMessageAtTime(Handler.java:473)
01-22 21:03:50.109: E/JavaBinder(18076): at android.os.Handler.sendMessageDelayed(Handler.java:446)
01-22 21:03:50.109: E/JavaBinder(18076): at android.os.Handler.sendMessage(Handler.java:383)
01-22 21:03:50.109: E/JavaBinder(18076): at android.app.ActivityThread.queueOrSendMessage(ActivityThread.java:1834)
01-22 21:03:50.109: E/JavaBinder(18076): at android.app.ActivityThread.access$200(ActivityThread.java:123)
01-22 21:03:50.109: E/JavaBinder(18076): at android.app.ActivityThread$ApplicationThread.schedulePauseActivity(ActivityThread.java:505)
01-22 21:03:50.109: E/JavaBinder(18076): at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:78)
01-22 21:03:50.109: E/JavaBinder(18076): at android.os.Binder.execTransact(Binder.java:338)
01-22 21:03:50.109: E/JavaBinder(18076): at dalvik.system.NativeStart.run(Native Method)
答案 0 :(得分:1)
日志表明您正在尝试重用Message对象。不要那样做;为每条消息获取一个新的Message对象。
所以,使用新鲜的消息解决了我的问题。因为他甚至在我要求他这样做之后也没有发表他的回答,所以我可以接受他的回答。
所以我自己做。
谢谢:)
答案 1 :(得分:0)
发送相同的消息对象两次或多次也可能导致此问题。因此,请查看您的代码并检查问题。我的原因就在这里。