Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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

I had interstitial ad just before user exit the app. This is excerpts of email that I received from admob. After receiving this email, I removed the interstitial ads completely and resubmitted the app.

Violation explanation

LAYOUT ENCOURAGES ACCIDENTAL CLICKS - INTERSTITIAL ADS: Publishers are not permitted to encourage users to click AdMob interstitial ads in any way. This includes any implementation that may encourage accidental clicks, such as placing an interstitial ad in a way that prevents viewing the app’s core content or placing an interstitial ad in a way that interferes with navigating or interacting with the app’s core content and functionality.

Please review how you’ve implemented interstitial ads and be mindful of the following common examples of non-compliant implementations:

  • Interstitial ads that appear before the app has opened or after the app has closed.
  • Interstitial ads that are triggered after a user closes another interstitial ad.
  • Interstitial ads loading unexpectedly while a user is viewing the app’s content. Remember to only serve interstitials between pages of content.
  • Interstitial ads that trigger after every user click.
  • Interstitial ads that appear during periods of game play or heavy user interaction.

For more information about our policies and tips for how to comply please read the following:

AdMob ad placement policy AdMob interstitial ad guidance

Action required: Check account for compliance While ad serving has been disabled to the above app, your AdMob account remains active. We suggest that you take the time to review the rest of your applications to ensure that they’re in compliance with our policies, and to monitor your apps accordingly to reduce the likelihood of future policy emails from us. Additionally, please note that our team reserves the right to disable accounts at any time if we continue to see violations occurring.

Do not place your ads at the exit of the app as it goes against admob policy.

This is not allowed as per admob policy

Please checkout this link

A bit late but.. I' ll reply for others this is my code.

This is one way, detect when user press Back Button and show a dialog with a positive and negative and if they press "Yes" call your interstitial method.

Greetens

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub

    if (keyCode == KeyEvent.KEYCODE_BACK) {

        AlertDialog.Builder alert = new AlertDialog.Builder(
                MainActivity.this);
        alert.setTitle(R.string.app_name);
        alert.setIcon(R.drawable.ic_launcher);
        alert.setMessage(R.string.quit);

        alert.setPositiveButton("Yes",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,
                            int whichButton) {
                                                //call your method here then finish activity;

                        interstitial();

                        finish();
                    }



                });

    alert.setNegativeButton("No",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }
            });
    alert.show();
    return true;
}

return super.onKeyDown(keyCode, event);

}
@Override
public void onBackPressed() {
   Log.d(TAG, "onBackPressed Called");
   displayInterstitial();

   finish();

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top