用户无法在错误后购买不同的商品:"您尝试购买的商品无法找到"

时间:2014-04-02 09:58:43

标签: android android-asynctask in-app-purchase in-app-billing

我正在使用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。

1 个答案:

答案 0 :(得分:0)

在做了更多的研究后,我发现这个样本,就像谷歌的其他样本一样,已知非常错误。我不确定最好的解决办法是什么,但现在我使用以下检查

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

之前打电话

mHelper.queryInventoryAsync(mGotInventoryListener);

mHelper.launchPurchaseFlow(...)