在开发游戏/应用的过程中,如果出现: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同一线程中