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

原创 2015年11月17日 20:16:12

在开发游戏/应用的过程中,如果出现:java.lang.RuntimeException: Can't create handler inside threadthat has not called Looper.prepare()

这种报错,可以查看log知道,大概的原因是因为在你的这个线程中调用了其与其余线程中的activity 

解决方法:

需要这同样的线程中调用只需要创建一个handler

Handler handler = new Handler();

Runnable EnentRun = new Runnable()
{
public void run()
{

//做你需要的事情......

handler.removeCallbacks(this);

}

}

handler.post(EnentRun);

这样就可以使其在activity同一线程中

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Android java.lang.RuntimeException: Can't create handler inside thread that has not called

在Android 5.1开发中遇到问题: 调用android.net.ethernet.EthernetManager出现问题,打印日志如下 升级代码中  FHUbootReceiver 中126...

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中不允许Activity里新启动的线程访问该Activity里的UI组件,这样会导致新启动的线程无法改变UI组件的属性值。 出现java.lang.RuntimeException:...

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

(1) Looper类用来为一个线程开启一个消息循环。 默认情况下Android中新诞生的线程是没有开启消息循环的。(主线程除外,主线程系统会自动为其创建Looper对象,开启消息循环)Looper...

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

(1) Looper类用来为一个线程开启一个消息循环。 默认情况下Android中新诞生的线程是没有开启消息循环的。(主线程除外,主线程系统会自动为其创建Looper对象,开启消息循环) Loop...

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

在解决这个问题时,觉得以下比较有用 为了正确的使用AsyncTask类,以下是几条必须遵守的准则:   1) Task的实例必须在UI thread中创建   2) execute方法必须在...

Android 异常 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper

调用 handler 使用报错java.lang.RuntimeException: Can't create handler inside thread that has not called Lo...

线程 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepa

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 notcalled Looper.prepare()

ANDROID-LOPPER类的介绍(HANDLER背后的类) 转载来自:http://www.open-open.com/lib/view/open1325668588515.html An...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)