Android开发报错 Can't create handler inside thread that has not called Looper.prepare()
2017-05-09 16:23
531 查看
错误信息:在Android开发中,从主线程调用非主线程中的方法,程序就直接挂掉,异常信息是:Can't create handler inside thread that has not called Looper.prepare()
原因分析:在非主线程中调用Toast提示,然后当程序运行到Toast的地方的时候程序就直接挂掉了
解决方法:在调用Toast(或者AlertDialog)的地方的前面加上Looper.prepare(),后边加上Looper.loop()即可解决问题;也就是说用Looper.prepare()和Looper.loop()把Toast前后包起来
原因分析:在非主线程中调用Toast提示,然后当程序运行到Toast的地方的时候程序就直接挂掉了
解决方法:在调用Toast(或者AlertDialog)的地方的前面加上Looper.prepare(),后边加上Looper.loop()即可解决问题;也就是说用Looper.prepare()和Looper.loop()把Toast前后包起来
相关文章推荐
- Android开发报错 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()的问题
- Android蓝牙开发,报BluetoothAdapter﹕ Can't create handler inside thread that has not called Looper.prepare
- Looper如何和一个线程进行绑定,以及Android中的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()
- 记录一次因为Android版本不同导致的crash异常:Can't create handler inside thread that has not called Looper.prepare()
- Android 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()
- Android中的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()
- Android在Activity中启动一个新进程报错:Can't create handler inside thread that has not called Looper.prepare()。
- Unity3d for android 访问UI控件报错 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()
- Android 异常 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper
- 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()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()