2014-01-20 36 views
0

我正在集成Android應用內結算api。但由於在某處出現異常,我丟失了purchaseToken。現在在API 3中,如果不消費購買的產品,我無法重新購買它。我現在無法消費,因爲我沒有purchaseToken?如何檢索它? 或者我可以重置購買?應用內付費API的Lost purchaseToken Api

回答

0

你可以通過查詢購買得到它。

下面是來自谷歌的例子:http://developer.android.com/google/play/billing/billing_integrate.html#billing-download

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { 
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) { 
     Log.d(TAG, "Query inventory finished."); 

     // Have we been disposed of in the meantime? If so, quit. 
     if (mHelper == null) return; 

     // Is it a failure? 
     if (result.isFailure()) { 
      complain("Failed to query inventory: " + result); 
      return; 
     } 

     Log.d(TAG, "Query inventory was successful."); 

     /* 
     * Check for items we own. Notice that for each purchase, we check 
     * the developer payload to see if it's correct! See 
     * verifyDeveloperPayload(). 
     */ 

     // Do we have the premium upgrade? 
     Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM); 
     .... 

    //<- here you can consume your purchase 

}