0

我正在使用TrivialDrive example为我的应用创建应用内购买。我故意造成的错误用户在出现错误后无法购买其他商品:“您试图购买的商品无法找到”

The item you were attempting to purchase could no be found 

但我找不到代码中发生错误。我需要知道的原因是,一旦发生此错误(或其他一些错误),用户不能再购买任何其他东西,而无需重新启动应用程序。这是由于这样的事实:flagEndAsync()只是消费过程中调用,这样,如果用户试图去其他地方购买的东西,然后应用程序会抛出异常

void flagStartAsync(String operation) { 
     if (mAsyncInProgress) { 
      throw new IllegalStateException("Can't start async operation (" + 
       operation + ") because another async operation(" + mAsyncOperation + ") is in progress."); 
     } 
     mAsyncOperation = operation; 
     mAsyncInProgress = true; 
     logDebug("Starting async operation: " + operation); 
    } 

我需要能够安全地终止的AsyncTask中的情况下,这样的错误。

回答

0

在做了更多的研究之后,我发现这个样本与Google的其他样本一样,都是非常有问题的。我不知道最好的解决办法是什么,但现在我用下面的检查

if (mHelper != null) { 
    mHelper.flagEndAsync(); 
} 

调用

mHelper.queryInventoryAsync(mGotInventoryListener); 

mHelper.launchPurchaseFlow(...) 
相关问题