问题:
今天在接入爱贝支付平台的时候,出现一个错误:
01-2818:00:05.614:E/AndroidRuntime(25801):FATALEXCEPTION:GLThread5466
01-2818:00:05.614:E/AndroidRuntime(25801):java.lang.RuntimeException:Can'tcreatehandlerinsidethreadthathasnotcalledLooper.prepare()
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.os.Handler.<init>(Handler.java:121)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.Dialog.<init>(Dialog.java:142)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.AlertDialog.<init>(AlertDialog.java:114)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.AlertDialog.<init>(AlertDialog.java:110)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.ProgressDialog.<init>(ProgressDialog.java:96)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.ui.widget.IPayLoadingDialog.<init>(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.showPrograssBar(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.begSession(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.onPreCallPayHub(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.IAppPay.startPay(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.zssbd.zjd.IZhiAppPay.startPayhub(IZhiAppPay.java:39)
01-2818:00:05.614:E/AndroidRuntime(25801): atorg.cocos2dx.lib.Cocos2dxRenderer.nativeRender(NativeMethod)
01-2818:00:05.614:E/AndroidRuntime(25801): atorg.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:94)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
01-2818:00:05.614:E/AndroidRuntime(25801):java.lang.RuntimeException:Can'tcreatehandlerinsidethreadthathasnotcalledLooper.prepare()
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.os.Handler.<init>(Handler.java:121)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.Dialog.<init>(Dialog.java:142)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.AlertDialog.<init>(AlertDialog.java:114)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.AlertDialog.<init>(AlertDialog.java:110)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.app.ProgressDialog.<init>(ProgressDialog.java:96)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.ui.widget.IPayLoadingDialog.<init>(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.showPrograssBar(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.begSession(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.SDKMain.onPreCallPayHub(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.iapppay.sdk.main.IAppPay.startPay(UnknownSource)
01-2818:00:05.614:E/AndroidRuntime(25801): atcom.zssbd.zjd.IZhiAppPay.startPayhub(IZhiAppPay.java:39)
01-2818:00:05.614:E/AndroidRuntime(25801): atorg.cocos2dx.lib.Cocos2dxRenderer.nativeRender(NativeMethod)
01-2818:00:05.614:E/AndroidRuntime(25801): atorg.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:94)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
01-2818:00:05.614:E/AndroidRuntime(25801): atandroid.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
解决:
new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { } });