Can't create handler inside thread that has not called Looper.prepare()
2016-11-29 18:58
706 查看
E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1 Process: PID: 3961 //这里是因为在子线程中进行了startActivity() java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.<init>(Handler.java:200) at android.os.Handler.<init>(Handler.java:114) at android.app.ActivityTransitionCoordinator.<init>(ActivityTransitionCoordinator.java:215) at android.app.ExitTransitionCoordinator.<init>(ExitTransitionCoordinator.java:75) at android.app.ActivityOptions.makeSceneTransitionAnimation(ActivityOptions.java:538) at com.hyphenate.chat.EMClient$6.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) E/WindowManager: android.view.WindowLeaked: Activity LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{b45027b V.E..... R......D 0,0-540,276} that was originally added here at android.view.ViewRootImpl.<init>(ViewRootImpl.java:382) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85) at android.app.Dialog.show(Dialog.java:310) at android.view.View.performClick(View.java:4785) at android.view.View$PerformClick.run(View.java:19884) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:147) at android.app.ActivityThread.main(ActivityThread.java:5513) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:970) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:765)
android.view.WindowLeaked: Activity LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{b45027b V.E….. R……D 0,0-540,276} that was originally added here
原因是:在跳转activity时,dialog 弹窗未销毁。调用dismiss 或者是cancel。java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()
这里是因为在子线程中进行了startActivity(),5.0以上就会crash5.0以上 我的写法是:
startActivity(intent,ActivityOptions.makeSceneTransitionAnimation(activity).toBundle());
5.0以下, 我的写法是:
activity.startActivity(intent);
相关文章推荐
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- can't create handler inside thread that has not called Looper.prepare
- java.lang.RuntimeException:Can‘t create handler inside thread that has not called Looper.prepare()
- android 开发遇到Can't create handler inside thread that has not called Looper.prepare()的问题
- Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare()解决办法
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare() 终极解决方法
- Android蓝牙开发,报BluetoothAdapter﹕ Can't create handler inside thread that has not called Looper.prepare
- Can't create handler inside thread that has not called Looper.prepare()解决办法
- Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare()
- Android开发报错 Can't create handler inside thread that has not called Looper.prepare()
- 解决Can't create handler inside thread that has not called Looper.prepare() inside AsyncTask
- Can’t create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()