Search code examples
androidadmobinterstitial

Admob - How to pause interstitial ad


Is there any way to pause/resume an Admob interstitial ad on Android? I give rewards for watching video ads and I want a dialog box to pop up when the user clicks the back button (the ad should pause first). E.g. Do you wish to forfeit the reward? Yes/No

Also I would like the ad to pause if the app is put in the background and then resume when the app is brought back to the front.

I can't find anything on the Admob website and other questions on this site have not solved the problem eg How to pause interstitial Ads when Android application goes to background?

I imagine I need to put something here:

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {          

        }           

        @Override
        public void onAdLoaded() {

        }

    });

And likely in here too:

@Override
protected void onPause() {
    super.onPause();

}

@Override
protected void onResume() {
    super.onResume();

}

@Override
public void onBackPressed() {   

}

I have seen ads pause in other apps so I know it's possible. Is there a simple pause method?


Solution

  • There is RewardedVideoAd by AdMob for your requirement. If you're using AdMob with Firebase, you can easily integrate Reward video Ad in your App.

    RewardVideoAd having resume(), pause() and destroy() method, call it in your Activity's onResume(), onPause() and in onDestroy() method respectively.