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()

在解决这个问题时,觉得以下比较有用 为了正确的使用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...
  • magiz19
  • magiz19
  • 2013年09月16日 11:17
  • 7384

线程 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...

错误解决 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不能在线程里面更新UI...

解决异常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(),是因为新new的线程中出...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
举报原因:
原因补充:

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