Android billing exception

前端 未结 4 2061
暗喜
暗喜 2020-12-14 16:52

I am testing my billing and I got this exception:

java.lang.IllegalStateException: Can\'t start async operation (launchPurchaseFlow) because another async op         


        
4条回答
  •  暖寄归人
    2020-12-14 17:54

    The IabHelper will only allow a single asynchronous query to be executed at a time. You need to implement onActivityResult() and pass the parameters into the handleActivityResult() method of the IabHelper.

    The in-app billing sample code implements the method like this:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
    
        // Pass on the activity result to the helper for handling
        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
            // not handled, so handle it ourselves (here's where you'd
            // perform any handling of activity results not related to in-app
            // billing...
            super.onActivityResult(requestCode, resultCode, data);
        }
        else {
            Log.d(TAG, "onActivityResult handled by IABUtil.");
        }
    }
    

提交回复
热议问题