Android Exception 13(Can't create handler inside thread that has not called Looper.prepare())

时间:2021-11-12 00:23:43
10-12 17:02:55.500: E/AndroidRuntime(28343): FATAL EXCEPTION: Timer-2

10-12 17:02:55.500: E/AndroidRuntime(28343): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

10-12 17:02:55.500: E/AndroidRuntime(28343):     at android.os.Handler.<init>(Handler.java:197)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at android.os.Handler.<init>(Handler.java:111)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at android.widget.Toast$TN.<init>(Toast.java:339)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at android.widget.Toast.<init>(Toast.java:98)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at android.widget.Toast.makeText(Toast.java:245)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at com.tongyan.activity.gps.SectionIndexAct$5.handleMessage(SectionIndexAct.java:503)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at com.tongyan.activity.gps.SectionIndexAct$9.run(SectionIndexAct.java:426)

10-12 17:02:55.500: E/AndroidRuntime(28343):     at java.util.Timer$TimerImpl.run(Timer.java:284)

10-12 17:02:56.270: E/WindowManager(28343): Activity com.tongyan.activity.gps.SectionIndexAct has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41525f48 V.E..... R......D 0,0-67,67} that was originally added here

10-12 17:02:56.270: E/WindowManager(28343): android.view.WindowLeaked: Activity com.tongyan.activity.gps.SectionIndexAct has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41525f48 V.E..... R......D 0,0-67,67} that was originally added here

10-12 17:02:56.270: E/WindowManager(28343):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:382)

10-12 17:02:56.270: E/WindowManager(28343):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:219)

10-12 17:02:56.270: E/WindowManager(28343):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)

10-12 17:02:56.270: E/WindowManager(28343):     at android.app.Dialog.show(Dialog.java:281)

10-12 17:02:56.270: E/WindowManager(28343):     at com.tongyan.activity.gps.SectionIndexAct.collectPoint(SectionIndexAct.java:392)

10-12 17:02:56.270: E/WindowManager(28343):     at com.tongyan.activity.gps.SectionIndexAct$GpsSectionMenuListAdapter$1.onClick(SectionIndexAct.java:577)

10-12 17:02:56.270: E/WindowManager(28343):     at android.view.View.performClick(View.java:4219)

10-12 17:02:56.270: E/WindowManager(28343):     at android.view.View$PerformClick.run(View.java:17422)

10-12 17:02:56.270: E/WindowManager(28343):     at android.os.Handler.handleCallback(Handler.java:725)

10-12 17:02:56.270: E/WindowManager(28343):     at android.os.Handler.dispatchMessage(Handler.java:92)

10-12 17:02:56.270: E/WindowManager(28343):     at android.os.Looper.loop(Looper.java:137)

10-12 17:02:56.270: E/WindowManager(28343):     at android.app.ActivityThread.main(ActivityThread.java:5119)

10-12 17:02:56.270: E/WindowManager(28343):     at java.lang.reflect.Method.invokeNative(Native Method)

10-12 17:02:56.270: E/WindowManager(28343):     at java.lang.reflect.Method.invoke(Method.java:511)

10-12 17:02:56.270: E/WindowManager(28343):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)

10-12 17:02:56.270: E/WindowManager(28343):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

10-12 17:02:56.270: E/WindowManager(28343):     at dalvik.system.NativeStart.main(Native Method)

 

原因是你在子线程里去handleMessage了,至于具体分析,还请自行google