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.
After you've set up an app in AdMob and added an ad unit to it, the last step is to implement the ad unit in your app's code. Follow the instructions in the Google Developers Get Started guide for Android or iOS. You'll need your app ID and ad unit ID during implementation.
I use option menu button to go to second activity. When user click on that menu button interstitial Ad show after launching second activity.
ACTION_DOWN, KeyEvent. KEYCODE_BACK)); As whenever you press on back button the interstitial ad is closed so firing the back button event will eventually close the interstitial ad.
I just had a nice talk with an employee at Admob about how to increase my ad revenue. And his recommendation was to add an interstitial when the players exit my game apps. I did not read through all the terms and conditions but I do believe that the Admob official knows the standard regulations and would not recommend this behavior if it was not allowed.
Technically I am going to implement it in this way:
1) Catch when the user clicks on my exit button or hits the back button on the main screen
2) Check if an interstitial is loaded and ready to be displayed
-> 3a) if it is not ready, i let the user quit without delay
-> 3b) if it is ready, I show the interstitial and listen to it being closed, when it is closed, I exit the app automatically
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With