2015-10-17 49 views
0

我目前在我的應用程序中有implementing inAppBilling(v3),遇到了一個小問題。我購買指南中的代碼:Android,In App Billing,getBuyIntent(),Activity.RESULT_OK,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; 

和測試我有一個靜態的應用程式內購買的應用程序,我得到的resultCode爲-1,如果購買成功。

那麼-1和1都表示成功購買?爲什麼Activity-class與指南中描述的不同?

回答

0

有兩種類型的響應代碼。結算響應代碼(有8個)包括您在準則中提到的「確定」的0,但此代碼包含在發送回活動的包中,而不是活動結果代碼。請參閱http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent希望這有助於

+0

本答案對您有任何用處Salatkopf? – Kalininskaya

+0

我瞭解計費響應代碼(0-8)和結果代碼(-1,0,1)之間的差異。我還閱讀了您發佈的參考鏈接,這正是我在原始問題中引用的地方!我想知道,當** RESULT_FIRST_USER **返回到onActivityResult() – mtosch

+0

它在這裏解釋:http://stackoverflow.com/questions/32013948/will-someone-please-explain-result-first-user – Kalininskaya