Unity-Android: Can't create handler inside thread

Unity-Android: Can't create handler inside thread that has not called Looper.prepare()


[+]

在做unity-android的过程中,遇到这个错误:

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

在主线程中创建Handler,sendMessage的时候,报这个错。

解决方法特别简单,在创建handler的时候,指明消息队列在那个looper中就可以了。

即,在创建Handler的时候:

Handler mHandler=new Handler(Looper.getMainLooper());


你可能感兴趣的:(Unity-Android: Can't create handler inside thread)