原文:在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()

在子线程中new一个Handler为什么会报以下错误 java.lang.RuntimeException: Can tcreatehandlerinsidethreadthathasnotcalledLooper.prepare 这是因为Handler对象与其调用者在同一线程中,如果在Handler中设置了延时操作,则调用线程也会堵塞。每个Handler对象都会绑定一个Looper对象,每个Lo ...

2016-08-02 22:17 0 52188 推荐指数:

查看详情

Can't create handler inside thread that has not called Looper.prepare()

最近做项目时出现个问题。 在一个基类,创建一个Handler对象用于主线程线程发送数据,代码如下 但不知道为啥一直报错Can't create handler inside thread that has not called Looper.prepare()。 搜索后 ...

Mon Jan 14 00:10:00 CST 2013 3 133790
Can't toast on a thread that has not called Looper.prepare()

Android开发Can't toast on a thread that has not called Looper.prepare()问题 说一下问题出现场景:   在一个Android项目中,利用okhttp进行网络访问判断用户输入的账号密码,当用户密码输错时弹出 Toast 进行提示 ...

Tue Nov 26 01:04:00 CST 2019 0 419
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM