Can't create handler inside thread that has not called Looper.prepare()
来源:互联网 发布:视频剪辑用什么软件 编辑:程序博客网 时间:2024/05/08 08:44
简单说在非主线程内调用handler去接收消息,频繁的话就会出现这个错误,意思是缺少Looper,那么怎么解决呢?
很幸运找到一个解决办法的博客,作者昵称sonicit,具体解决办法如下:
this.mThirdHandler = new Handler(mContext.getMainLooper()){ @Override public void handleMessage(android.os.Message msg) { }; };在new Handler的时候可以指定Looper故给非主线程的Handler实例化的时候需要
new Handler(mContext.getMainLooper())指定主线程的Looper即可解决问题。
解释一下,一个主进程只能有一个Looper所以需要指定用主进程的Looper。
0 0
- 解决Can't create handler inside thread that has not called Looper.prepare() inside AsyncTask
- Handler——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()异常
- 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()
- 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() 终极解决方法
- 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()解决办法
- Android View的工作原理
- 如何在项目里面使用freemarker实现页面缓存(三)
- 认识GNU GPL发展Linux
- 2016android新技术之DataBinding
- 【小白笔记】KCF目标跟踪算法Matlab代码运行指南
- Can't create handler inside thread that has not called Looper.prepare()
- 董西城问答整理:第三课
- android进度条样式
- 算法-第四版-练习1.3.14解答
- SSE(Server-Send Event):服务器推送数据的新方式
- 快速学习JS的思考方法、有用
- word双栏排版,最后一页由于分节符造成最后一页是空白页,删除分节符双栏就变成了单栏
- Could not find Developer Disk Image
- 判断List为空