鸟语天空
java.lang.RuntimeException
post by:追风剑情 2015-6-25 11:20

Android报错

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

at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at com.kakao.api.KakaoResponseHandler.<init>(KakaoResponseHandler.java:22)
at com.zwwx.sgzs.kakao.KakaoFacade$1.<init>(KakaoFacade.java:135)
at com.zwwx.sgzs.kakao.KakaoFacade.logout(KakaoFacade.java:135)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


原因: 在其他线程中更新UI导致。

解决方案:


UnityPlayer.currentActivity.runOnUiThread(new Runnable(){
   public void run(){
     //这里的代码会在UI线程中执行
     //do something
   }
});


评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容