title: Android In App Billing: Can't start launchPurchaseFlow because launchPurchaseFlow is in progress
body: <p>I'm implementing In App Billing for the first time and I'm testing my first purchases using the static SKU ids. </p>
  
  <p>It worked very well the first time. I called <code>mHelper.launchPurchaseFlow(...)</code> and completed the test purchase. My activity received the <code>onActivityResult</code> callback and I made sure to process it with <code>mHelper.handleActivityResult(...)</code>. Everything was great. </p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // Pass on the activity result to the helper for handling
      log("onActivityResult");
      if (!this.mHelper.handleActivityResult(requestCode, resultCode, data)) {
          log("cleared the launch flow");
          // 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);
      }
  }
  </code></pre>
  
  <p>However, I wanted to test the next part, so I relaunched the app and tried to purchase the same SKU (the static <code>purchased</code> SKU). </p>
  
  <pre><code>mHelper.launchPurchaseFlow(rootActivity, "android.test.purchased", 10002,   
         new IabHelper.OnIabPurchaseFinishedListener() {
  
          @Override
          public void onIabPurchaseFinished(IabResult result, Purchase purchaseInfo) {
              if (result.isFailure()) {
                  log("purchased failed");
              } else {
                  log("purchase succeeded");
              }
          }
      }, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
  </code></pre>
  
  <p>The second time I try to purchase the item, my <code>OnIabPurchaseFinishedListener</code> is called and I see <code>purchase failed</code> in my log: "In-app billing error: Unable to buy item, Error response: 7:Item Already Owned"</p>
  
  <p>That makes sense, but if I try to purchase another item, then my app crashes with the following error:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Can't start async operation
    (launchPurchaseFlow) because another async
    operation(launchPurchaseFlow) is in progress.</p>
  </blockquote>
  
  <p>The <code>onActivityResult</code> callback doesn't happen when I try to do the purchase that fails, so the launch flow that failed doesn't get handled and cleaned up. So, when I try another purchase, that's why it crashes because it's still supposedly in the middle of the last failed transaction.</p>
  
  <p>What am I doing wrong? How do I ensure that the launchPurchaseFlow() is cleaned up after a failure?</p>