TL;DR: According to the documentation there are two different ways to purchase a product, which do I use? Do I use an intent or IABHelper.launchPurchaseFlow()
?
According to this documentation, use launchPurchaseFlow();
and attached listener to make a purchase:
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener =
new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
//Item bought...? Why should I use this option
}
};
mHelper.launchPurchaseFlow(this, SKU_GAS, 10001,
mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
However, according to this documentation, I must use intents and onActivityForResult()
to purchase a product:
startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
Integer.valueOf(0));
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1001) {
if (resultCode == RESULT_OK) {
//Item bought...? Why should I use this option
}
}
}
Which method should I use to purchase the product? Both options seem extremely similar, but what is the difference, and is one better?