'There is no onActivityResult() in Fragment. For in-app Billing

I am following the tutorial and code examples from Google on how to implement in-app Billing. The thing is that I'm doing this in a Fragment.

Up until the last step everything seem to implement alright, but then I'm supposed to implement this method:

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

And the problem is of course that this protected method doesn't exist in the fragment. There is only a public method, that doesn't get called when finishing a in-app purchase.



Solution 1:[1]

These Links are probably helpful

http://code.google.com/p/marketbilling/issues/detail?id=131

Calling startIntentSenderForResult from Fragment (Android Billing v3)

Solution 2:[2]

a simpler solution can be this

create a method in main activity set the mhelper instance from fragment to main activity with that method and use that instance in onActivity result

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 khoshrang