我使用计费进行新的应用内购买。
我有计费助手和计费接收器类。
如何从计费助手或计费接收器购买商品后获取响应代码。
谢谢。
问问题
1486 次
2 回答
3
在启动购买流程时传入的 OnIabPurchaseFinishedListener 中
mIabHelper.launchPurchaseFlow(this, SKU_TEST_PURCHASED, TEST_PURCHASED_REQUEST_CODE, mPurchaseFinishedListener, developerPayload);
这是示例代码
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener()
{
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info)
{
Log.d("onIabPurchaseFinished", "Purchase finished: " + result + ", purchase: " + info);
if(result.isFailure())
{
complain("Error purchasing: " + result);
return;
}
Log.d("onIabPurchaseFinished", "Purchase successful.");
if(info.getSku().equals("android.test.purchased"))
{
Log.d("onIabPurchaseFinished", "Purchase is android.test.purchased");
mIabHelper.consumeAsync(info, mConsumeFinishedListener);
}
}
};
于 2013-05-16T07:45:20.783 回答
0
我从https://codeload.github.com/blundell/SimpleInAppPurchaseV3/zip/master下载了代码
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (Navigator.REQUEST_PASSPORT_PURCHASE == requestCode) {
if (RESULT_OK == resultCode) {
dealWithSuccessfulPurchase();
} else {
dealWithFailedPurchase();
}
}
}
private void dealWithSuccessfulPurchase() {
Log.d("Passport purchased","Passport purchased");
popToast("Passport purchased");
}
private void dealWithFailedPurchase() {
Log.d("Passport purchase failed","Passport purchase failed");
popToast("Failed to purchase passport");
}
于 2013-05-16T11:33:07.963 回答