後處置labHelper谷歌錢包的我整合谷歌錢包,並開始labHelper在buying.Normally labHelper的開頭是在開始活動的時間的onCreate和在處置活動時間onDestroy。因此,即使我們沒有使用錢包服務labHelper是在活動開始時創建的。安卓:如何購買
所以我想在開始購買的時候開始labHelper和labhelperPurchase完成監聽器處理。我在購買後出現異常情況,但貨幣轉賬也在那裏發生。
一次購買後,當我嘗試購買第二次顯示 「事務失敗」
LabHelper Intialization
mHelper = new IabHelper(FrendyActivity.this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null)
return;
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
} else {
Log.d(TAG, "In-app Billing is set up OK");
}
}
});
採購這是處置
代碼後mHelper.launchPurchaseFlow(FrendyActivity.this,
SkuItem, code,
mPurchaseFinishedListener, type);
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (mHelper != null)
mHelper.dispose();
mHelper = null
dealWithPurchaseSuccess(result, purchase);
}
一次購買後,當我再次嘗試購買producat我得到錯誤的labHelper已經開始
如何在購買後妥善處置labHelper?
可以粘貼購買項目的一些代碼.. – virendrao
更新,代碼@virendrao –
你確定這是申購代碼,因爲我記得我們稱之爲像launchPurchaseFlow .. – virendrao