What is needed in the onActivityResult method after a purchase flow has been launched?
From the Trivial Drive sample:
@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.");
}
}
"here's where you'd perform any handling of activity results not related to in-app billing"
Does it mean you need to update the user's inventory or display an alert box? If so, I do this already in the OnConsumeFinishedListener. I have tested my code leaving the onActivityResult method as above and it seems fine. Could this potentially cause any problems?
Or does it mean I must manually call the consume method for the SKU purchased?
Your code is fine if you have not to handle other results in your activity. Imagine an activity which e.g. start other activitys with startActivityForResult(). That's the place to handle those 'not related to in-app billing' results.
But then you should change the code to something like:
@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);
}