[英]Android in-app billing v3. onActivityResult
啟動購買流程后,onActivityResult方法中需要什么?
從瑣碎的驅動器示例:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mHelper == null) return;
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app
// billing...
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
“在這里您將對與應用內結算無關的活動結果進行任何處理”
這是否意味着您需要更新用戶的清單或顯示警報框? 如果是這樣,我已經在OnConsumeFinishedListener中做到了。 我已經測試了離開上述onActivityResult方法的代碼,這看起來還不錯。 這可能會引起任何問題嗎?
還是意味着我必須為購買的SKU手動調用消耗方法?
如果您不必在活動中處理其他結果,則您的代碼很好。 想象一個活動,例如,使用startActivityForResult()啟動其他活動。 這是處理“與應用內結算無關”結果的地方。
但是然后您應該將代碼更改為:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Pass on the activity result to the helper for handling
if (mHelper==null || !mHelper.handleActivityResult(requestCode, resultCode, data)) {
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app
// billing...
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
super.onActivityResult(requestCode, resultCode, data);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.