Android in-app billing: Can't start async operation because another async operation (is in progress)

前端 未结 19 760
星月不相逢
星月不相逢 2020-12-07 10:34

I am using the IabHelper utility classes, as recommended by Google\'s tutorial, and I\'m being hit hard by this error. Apparently IabHelper can not

19条回答
  •  情深已故
    2020-12-07 11:09

    A little-modified version of NadtheVlad's answer that works like charm

    private void makePurchase() {
    
        if (mHelper != null) {
            try {
                mHelper.launchPurchaseFlow(getActivity(), ITEM_SKU, 10001, mPurchaseFinishedListener, "");
            }
            catch(IllegalStateException ex){
                mHelper.flagEndAsync();
                makePurchase();
            }
        }
    }
    

    The logic is simple, just put the launchPurchaseFlow() thing in a method and use recursion in the catch block. You still need to make flagEndAsync() public from the IabHelper class.

提交回复
热议问题