I would like to add some IAPs to my Android 4+ app. This seems to be quite easy, but there is one problem: Google offers two tutorials that describe how to use the latest IAP API v3 which use pretty different implemenations. Which one is the better/correct one?
Implementing In-app Billing describes how to implement a 'ServiceConnection' to bind an activity to 'IInAppBillingService'. The service is used directly to do all the IAP stuff like querying product information or performing purchases.
Preparing Your In-app Billing Application on the other hand describes how to use the IabHelper class to connect to the Service and run all IAP related Stuff.
I am confused about how these two tutorials are connected. There is no information about the relationship between the tutorials and the different approaches they describe.
So far I think, that the IabHelper is just a wrapper that should help to use the IInAppBillingService
in a more convenient way. Is this right?
Using a convenience wrapper to make work with a complicated task more easy is often a good and nice idea. On the other hand a wrapper not only keeps the complicate implementations away from the developer but also the direct feedback/responses from the API. This can make debugging harder. Having this in mind: Which is the better solution? Using the API directly as described in the first tutorial or to use the IabHelper?
Google Play's billing system is a service that enables you to sell digital products and content in your Android app. You can use Google Play's billing system to sell a one-time product or subscriptions on a recurring basis.
These tutorials are nice to learn how IABv3 works. However, if you are in a hurry or need to add IAB to several apps, the simplest and fastest way is to use this library: https://github.com/anjlab/android-inapp-billing-v3
From my previous experience it is quite nice to read them both. And to use IabHelper
as example of the proper in app purchase flow. First tutorial describes how to use Billing API and other describes with code block how to implement this API. For the fast and reliable code try to use existing code from second tutorial with IabHelper
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With