how to show ad mob interstitial ad on app exit. I tried it using onBackPressed() method but getting errors Code for interstitial ad
interstitial = new InterstitialAd(this, "AD_ID");
AdRequest adRequest = new AdRequest();
interstitial.loadAd(adRequest);
interstitial.setAdListener(this);
}
@Override
public void onReceiveAd(Ad ad) {
if (ad == interstitial) {
interstitial.show();
}
}
What is the correct way to do it.
Don't attempt to show an Ad on app exit, as RSenApps says show it at a key point in your app instead.
If your problem is that when the interstitial shows it causes the views to be redrawn on your Activity, then you need to persist or cache the drawing state of your Activity so that previous state can be quickly redrawn as needed.