Android,In App Billing,getBuyIntent(),Activity.RESULT_OK,v3

时间:2015-10-17 18:43:43

标签: android response in-app-billing onactivityresult

我目前implementing inAppBilling(v3)进入我的应用程序并遇到了一个小问题。我使用指南中的代码购买了一件商品:

Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));

这会发送对onActivityResult()方法的响应。根据指南,resultCode是 Activity.RESULT_OK(1) Activity.RESULT_CANCELED(0)

但是查看Activity类,你会发现:

 /** Standard activity result: operation canceled. */
public static final int RESULT_CANCELED    = 0;
/** Standard activity result: operation succeeded. */
public static final int RESULT_OK           = -1;
/** Start of user-defined activity results. */
public static final int RESULT_FIRST_USER   = 1;

使用静态inApp-purchase测试我的应用程序,如果购买成功,我会得到resultCode -1。

-1和1都表示成功购买了吗?为什么Activity-class与指南中描述的不同?

1 个答案:

答案 0 :(得分:0)

有两种类型的响应代码。计费响应代码(有8个)包括您在指南中提到的0表示但是此代码包含在发送回活动的包中,而不是活动结果代码。见http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent希望这有帮助