Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Android InApp Billing V3 example. Hit Buy, Back Button, and buy again causes error

Here's the steps:

  1. Build and run the InApp V3 sample Trivial Drive example
  2. Select the buy option
  3. Hit the back button
  4. Try to buy again

In the version as of January 2013 You'll possibly receive

Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress.

Then you can not use the purchase or inventory methods of the IabHelper class, since the async flag will not clear, unless you kill your application.

Here's a possible solution:

I made the flagEndAsync method public and called it in the onRestart method. The questions are: is this a safe solution? And has anyone else seen this issue?

Here's what I added:

protected void onRestart() {
    super.onRestart();
    if (mHelper != null) mHelper.flagEndAsync();
}
like image 521
Ralph Yozzo Avatar asked Jan 19 '13 06:01

Ralph Yozzo


1 Answers

Are you sure you didn't remove the following code (or forgot to add to your activity)

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent 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);
        }
    }
like image 99
Ceetn Avatar answered Oct 19 '22 02:10

Ceetn