2014-04-10 48 views
3

我在使用應用內結算開發應用新的,我已經implmented,但一些 倍給我下面的錯誤 在-app計費錯誤:無法購買商品,錯誤應對:7:項目已經擁有 給我的解決方案就可以了應用內結算錯誤:無法購買商品,錯誤應對:7:項目已經擁有

+4

我討厭那些總是打倒別人的帖子的「專家」。所以我投票給你,雖然你的問題是不完整的。但我認爲任何遇到此問題的人都應該明白。 –

+0

非常感謝我們的投票 – asiya

回答

2

您需要再次購買之前要消耗的物品..

IabHelper mHelper = new IabHelper(ACTIVITY, base64EncodedPublicKey); 

@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    // Pass on the activity result to the helper for handling 
    if (!mHelper.handleActivityResult(requestCode, resultCode, data)) { 
     super.onActivityResult(requestCode, resultCode, data); 
    } 
    else { 
     Log.d(TAG, "onActivityResult handled by IABUtil."); 
    } 
} 
+0

我該怎麼做? – asiya

+0

mHelper.consumeAsync(YOUR SKU,finishListener); –

+0

請詳細解釋一下 – asiya

1

舉個例子在Android Developer site中給出的項目 命名爲TrivialDrive我們可以使用purch ased項目如下...

// Check for gas delivery -- if we own gas, we should fill up the tank immediately 
    Purchase gasPurchase = inventory.getPurchase(SKU_GAS); 
    if (gasPurchase != null && verifyDeveloperPayload(gasPurchase)) { 
     Log.d(TAG, "We have gas. Consuming it."); 
     mHelper.consumeAsync(inventory.getPurchase(SKU_GAS), mConsumeFinishedListener); 
     return; 
    } 

// Called when consumption is complete 
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() { 
    public void onConsumeFinished(Purchase purchase, IabResult result) { 
     Log.d(TAG, "Consumption finished. Purchase: " + purchase + ", result: " + result); 

     // if we were disposed of in the meantime, quit. 
     if (mHelper == null) return; 

     // We know this is the "gas" sku because it's the only one we consume, 
     // so we don't check which sku was consumed. If you have more than one 
     // sku, you probably should check... 
     if (result.isSuccess()) { 
      // successfully consumed, so we apply the effects of the item in our 
      // game world's logic, which in our case means filling the gas tank a bit 
      Log.d(TAG, "Consumption successful. Provisioning."); 
      mTank = mTank == TANK_MAX ? TANK_MAX : mTank + 1; 
      saveData(); 
      alert("You filled 1/4 tank. Your tank is now " + String.valueOf(mTank) + "/4 full!"); 
     } 
     else { 
      complain("Error while consuming: " + result); 
     } 
     updateUi(); 
     setWaitScreen(false); 
     Log.d(TAG, "End consumption flow."); 
    } 
}; 

希望!!!它幫助你。你可以通過這個例子項目。

+0

您是否知道無法購買錯誤5 - 開發人員錯誤> – keen

+0

RESULT_DEVELOPER_ERROR = 5 - 提供給API的無效參數可以在給定的IInAppBillingService.aidl中檢查 –

相關問題