Search code examples
androidadmobadsinterstitial

Android - OnDestroy remove interstitial ad?


This question is asked more, but there are different solutions given and I honestly don't know what the best practice is here.

I've got an interstitial ad like this (Google Admob SDK):

private InterstitialAd interstitial;

However the ad is delayed a bit and if a user quickly navigates (within a second or two), then the ads shows at a different screen than I would like, or even worse when the application is already in the background.

How to pause interstitial Ads when Android application goes to background? shows a function that doesn't exist (anymore).
When dismiss interstitial DFP ad on Android, the app crashes uses a different ad apparently than I do... is this better to use?
programmatically close an Interstitial ad simply says it's impossible to cancel it.

What i preferably would like it to just cancel the ad in the onDestroy() function and pause (or destroy aswell) the ad in the onPause() function.

Is this possible to do? Any workaround or what not is also fine, but I of course prefer a clean solution.


Solution

  • You should really have shown some code, but from your symptoms I suspect you are showing your Interstitial from the #onAdReceived method of an AdListener. DO NOT DO THIS

    You should be showing your Interstitial at a natural break point in your app instead. Otherwise you will get the behaviour described as well as provide an extremely poor user experience.