Android 应用内结算 v3。 onActivityResult
Android in-app billing v3. onActivityResult
购买流程启动后onActivityResult方法需要什么?
来自 Trivial Drive 示例:
@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.");
}
}
"here's where you'd perform any handling of activity results not related to in-app billing"
这是否意味着您需要更新用户的库存或显示警告框?如果是这样,我已经在 OnConsumeFinishedListener 中这样做了。我已经测试了我的代码,如上所示保留了 onActivityResult 方法,它看起来很好。这可能会导致任何问题吗?
还是说购买的SKU必须手动调用consume方法?
如果您不必在 activity 中处理其他结果,您的代码就可以了。
想象一个 activity 例如使用 startActivityForResult() 启动其他 activitys。
这是处理那些 'not related to in-app billing' 结果的地方。
但是您应该将代码更改为:
@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);
}
购买流程启动后onActivityResult方法需要什么?
来自 Trivial Drive 示例:
@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.");
}
}
"here's where you'd perform any handling of activity results not related to in-app billing"
这是否意味着您需要更新用户的库存或显示警告框?如果是这样,我已经在 OnConsumeFinishedListener 中这样做了。我已经测试了我的代码,如上所示保留了 onActivityResult 方法,它看起来很好。这可能会导致任何问题吗?
还是说购买的SKU必须手动调用consume方法?
如果您不必在 activity 中处理其他结果,您的代码就可以了。 想象一个 activity 例如使用 startActivityForResult() 启动其他 activitys。 这是处理那些 'not related to in-app billing' 结果的地方。
但是您应该将代码更改为:
@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);
}