我正在實現一個簡單的線程,它將消息傳遞給主UI線程,以便在UL中進行更改,但有時我得到此異常並無法弄清其確切原因。java.lang.RuntimeException:主線程循環意外退出,可能是什麼原因?
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 [email protected] } 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)
日誌說您正在嘗試重用Message對象。不要那樣做;爲每條消息獲取一個新的消息對象。如果你無法弄清楚,請發佈正在發送消息的代碼。 –
是的,我使用的是相同的消息對象。 Thnxs :)請張貼您的答案,以便我可以將其標記爲正常工作。 –