问题
I am trying to impliment android in app billing v3 and my application crashes with the following error Can't start async operation (consume) because another async operation(consume) is in progress
Stack trace is given below
02-25 16:56:54.811: E/AndroidRuntime(6913): FATAL EXCEPTION: main
02-25 16:56:54.811: E/AndroidRuntime(6913): java.lang.IllegalStateException: Can't start async operation (consume) because another async operation(consume) is in progress.
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.seven.BillingHelper.IabHelper.flagStartAsync(IabHelper.java:711)
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.seven.BillingHelper.IabHelper.consumeAsyncInternal(IabHelper.java:832)
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.seven.BillingHelper.IabHelper.consumeAsync(IabHelper.java:623)
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.seven.javalib.InAppBilling$15.run(InAppBilling.java:350)
02-25 16:56:54.811: E/AndroidRuntime(6913): at android.os.Handler.handleCallback(Handler.java:587)
02-25 16:56:54.811: E/AndroidRuntime(6913): at android.os.Handler.dispatchMessage(Handler.java:92)
02-25 16:56:54.811: E/AndroidRuntime(6913): at android.os.Looper.loop(Looper.java:143)
02-25 16:56:54.811: E/AndroidRuntime(6913): at android.app.ActivityThread.main(ActivityThread.java:4196)
02-25 16:56:54.811: E/AndroidRuntime(6913): at java.lang.reflect.Method.invokeNative(Native Method)
02-25 16:56:54.811: E/AndroidRuntime(6913): at java.lang.reflect.Method.invoke(Method.java:507)
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-25 16:56:54.811: E/AndroidRuntime(6913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-25 16:56:54.811: E/AndroidRuntime(6913): at dalvik.system.NativeStart.main(Native Method)
Can anyone please tell me how i can solve this
回答1:
For a reason in a previous try the method flagEndAsync
hasnot been called, make sure that in IabHelper
in all cases (success or failure) the method flagEndAsync
is called.
回答2:
This can happen because IabHelper.handleActivityResult(requestCode, resultCode, data);
is not called in the onActivityResult()
method of your activity. You may want to verify that it is being called.
回答3:
Instead of updating all code. It's easier to make the flagEndSync method in your IabHelper public.
Then each time you make call to your IabHelper, call Mhelper.flagEndAsync() first. Then you know for sure you start with a clean Asynctask.
No crashes for me anymore.
来源:https://stackoverflow.com/questions/15066095/illegalstateexception-in-iab-v3