gpt4 book ai didi

java - Android 应用内结算 v3. onActivityResult

转载 作者:行者123 更新时间:2023-11-30 01:55:12 25 4
gpt4 key购买 nike

启动购买流程后,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.");
}
}

“您可以在此处执行与应用内结算无关的任何 Activity 结果处理”

这是否意味着您需要更新用户的库存或显示一个警告框?如果是这样,我已经在 OnConsumeFinishedListener 中这样做了。我已经测试了我的代码,如上所示保留了 onActivityResult 方法,它看起来很好。这可能会导致任何问题吗?

还是说必须手动调用购买的SKU的consume方法?

最佳答案

如果您不必处理 Activity 中的其他结果,您的代码就可以了。想象一个 Activity ,例如使用 startActivityForResult() 启动其他 Activity 。这是处理那些“与应用内结算无关”结果的地方。

但是您应该将代码更改为:

@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);
}

关于java - Android 应用内结算 v3. onActivityResult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32363885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com