Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android应用内计费v3。onActivityResult_Java_Android_In App Billing_Onactivityresult - Fatal编程技术网

Java Android应用内计费v3。onActivityResult

Java Android应用内计费v3。onActivityResult,java,android,in-app-billing,onactivityresult,Java,Android,In App Billing,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.hand

启动采购流程后,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手动调用consume方法?

如果您不必在活动中处理其他结果,那么您的代码就可以了。 想象一个活动,例如使用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);
}

帮了我,谢谢。