Exception: Unable to start asynchronous operation (update inventory) because another async operation (launchPurchaseFlow) is running

Yes, there are two general answers to this problem:

One: hack where you call billingHelper.flagEndAsync();before starting async operation. This is usually considered not recommended and does not solve the problem in many cases.

Two: calling the IabHelper method handleActivityResultin Activity onActivityResult. The problem with this solution (besides me, which does not understand the purpose of this method) is that in my application the billing operations in the application are performed in the Application class application, because the application has a bunch of actions in which the user can start shopping in the application and several possible entry points where the application should request an inventory of purchases within the application. So I tried to put:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (!MyApplication.myAppInstance.mHelper.handleActivityResult(requestCode, resultCode, data))    
    super.onActivityResult(requestCode, resultCode, data);
}

in every action in which the user can start the purchase, but this did not solve the failures. I really don't understand the purpose of this material onActivityResult, so I probably misunderstood how it should be implemented. Why, in any case, does Google want to force me to do billing operations in the application?

+4
2

. , IabHelper ... , , , , .

- if-statement, :

if (!mHelper.isAsyncInProgress()) {
    mHelper.launchPurchaseFlow(...);
}

IabHelper ... , , , . , ... IabHelper , .

+11

PurchaseFlow . , , , "" Google In App BillingIntent. reset false. .

if(!mHelper.isAsyncInProgress())
{
    mHelper.launchPurchaseFlow(...);
}

// Invoke below method to reset onBackPressed
public static void resetAsyncInProgress() {
    mHelper.setAsyncInProgress(false);
}
+3

All Articles