Fragment中没有onActivityResult()。对于应用内结算

时间:2014-10-29 20:28:56

标签: java android in-app-billing

我正在关注如何实施应用内结算的Google中的教程和代码示例。问题在于我是在片段中做到这一点。

直到最后一步,一切似乎都没有实现,但是我应该实现这个方法:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + 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.");
        }
    }

问题当然是这种受保护的方法不存在于片段中。只有一种公共方法,在完成应用内购买时无法调用。