问题:
今天在接入爱贝支付平台的时候,出现一个错误:
01-28 18:00:05.614: E/AndroidRuntime(25801): FATAL EXCEPTION: GLThread 5466
01-28 18:00:05.614: E/AndroidRuntime(25801): java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.os.Handler.(Handler.java:121)
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.app.Dialog.(Dialog.java:142)
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.app.AlertDialog.(AlertDialog.java:114)
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.app.AlertDialog.(AlertDialog.java:110)
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.app.ProgressDialog.(ProgressDialog.java:96)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.iapppay.ui.widget.IPayLoadingDialog.(Unknown Source)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.iapppay.sdk.main.SDKMain.showPrograssBar(Unknown Source)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.iapppay.sdk.main.SDKMain.begSession(Unknown Source)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.iapppay.sdk.main.SDKMain.onPreCallPayHub(Unknown Source)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.iapppay.sdk.main.IAppPay.startPay(Unknown Source)
01-28 18:00:05.614: E/AndroidRuntime(25801): at com.zssbd.zjd.IZhiAppPay.startPayhub(IZhiAppPay.java:39)
01-28 18:00:05.614: E/AndroidRuntime(25801): at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)
01-28 18:00:05.614: E/AndroidRuntime(25801): at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:94)
01-28 18:00:05.614: E/AndroidRuntime(25801): at android.opengl.GLSurfaceViewGLThread.guardedRun(GLSurfaceView.java:1516)01?2818:00:05.614:E/AndroidRuntime(25801):atandroid.opengl.GLSurfaceViewGLThread.guardedRun(GLSurfaceView.java:1516) 01-28 18:00:05.614: E/AndroidRuntime(25801): at android.opengl.GLSurfaceViewGLThread.guardedRun(GLSurfaceView.java:1516)01?28 18:00:05.614: E/AndroidRuntime(25801): at android.opengl.GLSurfaceViewGLThread.run(GLSurfaceView.java:1240)
解决:
这是因为在cocos2dx opengl线程中调用android UI主线程的东西,解决方法:
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
}
});
————————————————
版权声明:本文为CSDN博主「tianxiawuzhei」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tianxiawuzhei/article/details/43964833