Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Adding In-App Purchases through Google Play is a somewhat complex process. The Google sample code is thousands of lines of code for you to add a custom implementation. If you're looking for something as easy as implementing an Amazon In-app Purchase, you can use the AndroidBillingLibrary from robotmedia. You can find this project at GitHub. This code simplifies Google Play In-App Purchases to reduce them down to 20 or 30 lines of code that you can mostly copy and paste. So you can download the ZIP file here, and you can see the implementation is fairly simple, and you're going to need to copy and paste this code inside of your Manifest.
So you can do that now, and then we're going to use the BillingController implementation. You will also need some information from the Android Developer Console. From the Android Developer Console, click Edit Profile. From here, scroll down and copy your Public Key as well, or you can just leave this page open for later, and paste it in when it's necessary. Let's go over to Eclipse. In Eclipse, I am going to open up my AndroidManifest.xml file. You'll need to add the permission com.android.vending.BILLING.
Here's where I've pasted my code, the robotmedia service. And then you'll need to bring in all the code files into your Eclipse project. To do that, open up the robotmedia project, and find the AndroidBillingLibrary. In the source folder, you'll see a com folder, and a net folder. The com folder contains the Android package for the vending library. So just drag this Android folder into your com folder. Don't overwrite your com folder, or also you may lose some of your existing files.
And then just drag that net folder right into the source folder for your project, and you can see that I've done that here. So inside of my source folder for my project, I have the net folder, and then in com, I have toddperkins and Android. After you've done that, jump back over to Eclipse and refresh or press F5, and you should see all of these classes imported in the source folder. If you have any warnings or errors when you do this, you can do two things; you can try cleaning your project, and you can go to Moleitx.java.
And if you see a line of code that imports android.r, delete it. Sometimes that line of code gets inserted automatically by Eclipse. Now, once you've imported all these classes into Eclipse, you've updated your Android Manifest and you're ready to start writing the code to adding In-App Purchases through Google Play.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101962 Viewers
61 Video lessons · 88680 Viewers
71 Video lessons · 72487 Viewers
56 Video lessons · 104183 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.