2

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.

Christoffer
  • 7,470
  • 9
  • 39
  • 55

1 Answers1

0

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

khoshrang
  • 146
  • 11