Search code examples
androidadmobinterstitial

Show interstitial ad more than once


Please help. The interstitial ad is shown only once. I want it to be shown more.

private void loadAds() {
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    interstitial = new InterstitialAd(this);
    AdRequest adRequest2 = new AdRequest.Builder().build(); //
    interstitial.setAdUnitId(getResources().getString(R.string.admob_interstitial));
    interstitial.setAdListener(new AdListener() {

        @Override
        public void onAdLoaded() {
            AdLoaded = true;
        }

        @Override
        public void onAdClosed() {
            super.onAdClosed();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            AdLoaded = true;
        }
    });

    interstitial.loadAd(adRequest2);
}

public void displayInterstitial() {
    if (adsCounter == 0) {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
        adsCounter = 0;
    } else {
        adsCounter += 2;
    }
}

Solution

  • Relpce OnAdClosed() with this

        @Override
              public void onAdClosed () 
              {
                  AdRequest adRequest = new AdRequest.Builder()
                    .build();
                  interstitial.loadAd(adRequest);
              }