zoukankan      html  css  js  c++  java
  • Android Exception 13(Can't create handler inside thread that has not called Looper.prepare())

    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

  • 相关阅读:
    Codeforces Round #614 (Div. 2) D. Aroma's Search
    Codeforces Round #614 (Div. 2) C. NEKO's Maze Game
    Kruskal最小生成树及应用
    Codeforces Round #608 (Div. 2) E. Common Number
    Codeforces Round #607 (Div. 2) D Beingawesomeism
    codeforce Hello 2020 A~E
    Codeforces Round #609 (Div. 2)
    Codeforces Round #607 (Div. 2) C. Cut and Paste
    Codeforces Round #605 (Div. 3) F. Two Bracket Sequences 三维dp
    2019-2020Nowcoder Girl初赛题解
  • 原文地址:https://www.cnblogs.com/royi123/p/4024743.html
Copyright © 2011-2022 走看看