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(...) 
相關問題