Can't create handler inside thread Thread that has not called Looper.prepare()
生活随笔
收集整理的这篇文章主要介绍了
Can't create handler inside thread Thread that has not called Looper.prepare()
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
今天在子线程里面写了一个Toast 运行程序直接崩溃了
看了下log 如下
最后忽然想到了子线程里面不能直接使用Toast
然后 就添加了 Looper.prepare(); 和 Looper.loop();
例如:
Looper.prepare();
Toast.makeText(MainActivity.this, "11111", Toast.LENGTH_SHORT).show();
Looper.loop();
这样运行好了
总结
以上是生活随笔为你收集整理的Can't create handler inside thread Thread that has not called Looper.prepare()的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 锅开头的成语有哪些?
- 下一篇: Volley 请求提示:com.andr