![](/img/trans.png)
[英]How to simulate onFailureListener & resultCode != Activity.RESULT_OK In App Updates?
[英]Android, In App Billing, getBuyIntent(), Activity.RESULT_OK, v3
我目前在我的應用程序中實現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購買測試我的應用程序,如果購買成功,則得到resultCode -1。
那么-1和1都表示購買成功嗎? 為什么Activity類與指南中描述的有所不同?
有兩種類型的響應代碼。 帳單響應代碼(有8個)包括您在准則中提到的OK(確定)0,但此代碼包含在發送回活動的捆綁銷售商品中,而不是活動結果代碼。 請參閱http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent希望對您有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.