我有一个使用应用内结算v3的应用程序,该应用程序没有任何错误,但是当我购买商品时,购买成功,但是最后一种方法称为
IabHelper.OnConsumeFinishedListener()
不称呼,购买成功后我不敬酒
那是我的代码
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (!mHelper.handleActivityResult(requestCode,
resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, is.com.raisse.battletheinfo.util.Purchase info) {
if (result.isFailure()) {
// Handle error
return;
} else if (info.getSku().equals(ITEM_SKU)) {
consumeItem();
}
}
};
public void consumeItem() {
mHelper.queryInventoryAsync(mReceivedInventoryListener);
}
IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// Handle failure
} else {
mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
mConsumeFinishedListener);
}
}
};
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
new IabHelper.OnConsumeFinishedListener() {
@Override
public void onConsumeFinished(is.com.raisse.battletheinfo.util.Purchase purchase, IabResult result) {
if (result.isSuccess()) {
int coin = storeValueClass.getValues(COIN,default_coin);
coin = coin +coinsBought;
storeValueClass.StoreValues(COIN,coin);
Toast.makeText(getActivity(), "purchase success", Toast.LENGTH_SHORT).show();
} else {
// handle error
Toast.makeText(getActivity(), "purchas not success", Toast.LENGTH_SHORT).show();
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
onCosumeFinished甚至没有调用的应用程序都告诉我购买成功有解决方案吗?