我是靠谱客的博主 愤怒麦片,这篇文章主要介绍Android在子线程里使用Toast报错Can't toast on a thread that has not called Looper.prepare(),现在分享给大家,希望可以做个参考。
在接android SDK的时候有时候为了方便debug调试查看,通过Toast输出相关信息,

实际上这个是在子线程中输出的,在logcat里查看有如下报错java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()。
解决办法为先调用Looper.prepare();再调用Toast.makeText().show();最后再调用Looper.loop();

最后
以上就是愤怒麦片最近收集整理的关于Android在子线程里使用Toast报错Can't toast on a thread that has not called Looper.prepare()的全部内容,更多相关Android在子线程里使用Toast报错Can't内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复