Skip to content

Simplest way to Remove Ads via IAP

Published on: April 14, 2018

Simplest way to Remove Ads via IAP

There are plenty of tutorials on the internet bout how to Remove Ads in your App via IAP on Android, but all are way harder & difficult for a beginner to understand. Someone with a little bit of Experience in Android will also find it a tad difficult.

In the beginning, even I faced problems with Android’s Own IAP library!

So here’s a simple tutorial for it.
This tutorial doesn't include parts like getting App’s API key & SKU (in app product name) from Play Developer Console.

  • Add the dependency as follows to grab the library –

    compile ''
  • Next step, create a private variable like below in your Activity -

    private BillingProcessor mBillingProcessor;
  • Initialize the BillingProcessor in the onCreate() like this –

    mBillingProcessor = new BillingProcessor(MainActivity.this, "Your App’s API String Key here", new BillingProcessor.IBillingHandler() {
      public void onProductPurchased(String productName, TransactionDetails transacDetails) {
        if (productName.equals("Product / SKU Name that you Created on Developer Console")) {
      @Override public void onBillingInitialized() {}
      @Override public void onPurchaseHistoryRestored() {}
      @Override public void onBillingError(int errorCode, Throwable throwable) {}

    What we did above was to Remove Ads when the payment is successful.

  • Now, init the library and remove ads if already purchased –

    if(mBillingProcessor.isPurchased("Your SKU Name")) relativelayout.removeView(mAdView);
  • You also need to override the onActivityResult() like this -

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (!mBillingProcessor.handleActivityResult(requestCode, resultCode, data)) {
          super.onActivityResult(requestCode, resultCode, data);

    Simple, isn’t it!?

    Okay, we have learnt how to handle AdView removal with purchase flow, but how do we start or call the Purchase?? Well, simply call below method and that’s it ✌️ –

    mBillingProcessor.purchase(MainActivity .this, "Your SKU Name");

Darshan Pandya