java.lang.RuntimeException

作者:追风剑情 发布于:2015-6-25 11:20 分类:Android

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
   }
});


标签: Android

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号