i_o
i_o

Reputation: 789

which way to implement in app billing?

After reading the android documentation on their developer website, I've realized that there are two ways to set up a purchase:

  1. create an IabHelper instance with a base64 string and use it to request some purchase... in no way it mentions that I have to use a ServiceConnection to bind the the IInAppBillingService for Android.

  2. There seems to be another way where you have to create a ServiceConnection that binds to the IInAppBillingService, where you have to create a Bundle etc.

Is it possible to use only the way where I just create the IabHelperinstance and call the methods on this instance that were acquired from the trivialDrive app ?

Upvotes: 3

Views: 331

Answers (3)

topcbl
topcbl

Reputation: 849

If you take a look at IabHelper class, you can see it contains every single pieces of code from Implementing In-App Billing tutorial.

So, Preparing Your In-app Billing Application provide a set of classes (IabHelper) that convenient for you to use In-App Billing v3.

Well, In my opinion, we should use IabHelper to get the best practice for the In-App Billing implementation. You also can write your own class in cáe of you need some extra purpose for the project.

Upvotes: 0

ranapnea
ranapnea

Reputation: 11

IABHelper internally uses ServiceConnection and binds to the service when you startSetup() on IABHelper. As docs state (http://developer.android.com/training/in-app-billing/preparing-iab-app.html), you still have to to include the .aidl file in your project for IInAppBillingService.

I strongly suggest to look for alternatives for IABHelper. Many developers (myself included) have found numerous bugs in its implementation. For example, the queryInventoryAsync implementation does not handle concurrency correctly. You will get a lot of crashes due to IABHelper if you use it.

There are numerous alternatives on GitHub.

Upvotes: 1

If you take a closer look at the Trivial Drive and its IabHelper class as described in Selling In-app Products you will notice that it indeed uses a ServiceConnection. I would recommend you to use the IabHelper, since it provides all boilerplate code you will need. Read up on the provided documentation though, especially the parts concerning security.

Upvotes: 0

Related Questions