Unity-Android: Can't create handler inside thread

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


[+]
java

在作unity-android的過程當中,遇到這個錯誤:

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

在主線程中建立Handler,sendMessage的時候,報這個錯。android

解決方法特別簡單,在建立handler的時候,指明消息隊列在那個looper中就能夠了。ide

即,在建立Handler的時候:oop

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

相關文章
相關標籤/搜索