android Toast提示异常:java.lang.RuntimeException: Can't create handler inside thread that has not called
来源:互联网 发布:淘宝网身份认证复核 编辑:程序博客网 时间:2024/06/07 13:41
android Toast提示异常:java.lang.RuntimeException: Can't create handler inside thread that has not called仔细检查了代码,不应该异常啊?? 没有 handler相关代码啊?原来是在子线程弹Toast了, 切记,Toast只能在UI线程弹出,如果一定要在子线程弹,那么就通过 new Handler(Looper.getMainLooper()) 来弹
private void toastTest() { new Thread(new Runnable() { @Override public void run() { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { //放在UI线程弹Toast Toast.makeText(MainActivity.this, "toast in work thread", Toast.LENGTH_LONG).show(); } }); //此处会发生异常 Toast.makeText(MainActivity.this, "toast in work thread", Toast.LENGTH_LONG).show(); } ).start(); }
阅读全文
0 0
- android Toast提示异常:java.lang.RuntimeException: Can't create handler inside thread that has not called
- android Toast提示异常:java.lang.RuntimeException: Can't create handler inside thread that has not called
- Android 异常 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper
- Android-java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- Android java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- android java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- Android java.lang.RuntimeException: 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
- android java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- 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()
- 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()
- 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()
- 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()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Android TimeUtils 时间工具类
- ARCGIS构建影像金字塔文件提高geoserver发布影像后的加载效率
- IDEA一些使用
- 匠牛社区AM5728 Canny实例
- Android 入门教程很有用的网站
- android Toast提示异常:java.lang.RuntimeException: Can't create handler inside thread that has not called
- Nexus3搭建Docker私有仓库并push镜像
- 十六进制转换的高效算法
- 培训:基于Kubernetes的DevOps实践
- gson改变输出字段的顺序
- Unity Attribute学习总结
- 输出100以内所有含7或7的倍数的值
- Delegate(委托)中的Covariance(协变)和Contravariance(逆变)
- #ifndef 和 #program once 的区别