In-app purchases
Another mechanism to monetize our application is to add in-app purchases. In-app purchases are, usually, microtransactions that can be used to enable specific functionality in our application. It is also very common to use in-app purchases to let the user purchase consumables or local in-game currency if, for instance, we develop a game.
Initial setup
One of the first things we have to do if we want to add support for in-app purchases in our application is to install Google Play Billing Library from the Android SDK Manager:
Google Play Billing Library provides us with an Android Interface Definition Language (AIDL) file; refer to https://developer.android.com/guide/components/aidl.html. Once we install this, we need to copy the In-app Billing Version 3 service interface definition called IInAppBillingService.aidl
to our project. The build system will automatically generate a Java class we can directly use from our code. By using this class, we will not have to manage...