Click here to see your recently viewed pages and most viewed pages.
Hide
AdMob Android Guides

Interstitial Ad

Interstitial ads are full screen ads that cover the interface of their host application. They're typically displayed at natural transition points in the flow of an application, such as between activities or during the pause between levels in a game. When an app shows an interstitial, the user has the choice to either tap on the ad and continue to its destination, or close it and return to the application. The direct call to action and larger size combine to make interstitials a particularly effective form of mobile advertisement.

Because of their larger size, interstitial ads require more bandwidth on average than traditional banners. To accommodate this, applications are required to load them asynchronously, in advance of when they will be displayed. This helps ensure that an ad is ready to go when the time comes to display one.

This guide explains how to integrate interstitial ads into your Android applications using the Google Mobile Ads SDK. It presents a simple activity class that uses SDK methods to preload and then display a test interstitial.

Helpful resources

If you haven't already completed it, consider running through the Android Quick Start for Mobile Ads.

Prerequisites

The sample code in this guide is from a project that has already included the Google Mobile Ads SDK. In order to use the SDK in your own application, you'll need to do the following in Android Studio:

or the following in Eclipse:

Adding interstitial ads to an activity

The recommended approach for an interstitial is to load it in advance, and then show it later when there's a natural pause in the flow of your application. Let's say, for example, that we have a simple game that runs for a while, ends, and then presents the user with a button to start again. Here's a code snippet that shows how to preload and display an interstitial before the user begins a new game:

...
public class MainActivity extends ActionBarActivity {

    InterstitialAd mInterstitialAd;
    Button mNewGameButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mNewGameButton = (Button) findViewById(R.id.newgame_button);

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
        requestNewInterstitial();

        mNewGameButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    beginPlayingGame();
                }
            }
        });

        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                requestNewInterstitial();
                beginPlayingGame();
            }
        });

        beginPlayingGame();
    }

    private void requestNewInterstitial() {
        AdRequest adRequest = new AdRequest.Builder()
                  .addTestDevice("YOUR_DEVICE_HASH")
                  .build();

        mInterstitialAd.loadAd(adRequest);
    }

    private void beginPlayingGame() {
        // Play for a while, then display the New Game Button
    }
}
...

Other than the introduction of a new member variable, mInterstitial, there are four places in the activity at which the code has changed. Let's take a look at them individually.

Instantiating the InterstitialAd object

...
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
requestNewInterstitial();
...

Here the member variable mInterstitialAd is constructed and given an ad unit ID. While banner ads are typically defined in an XML layout file, interstitial ads are not. They're created and configured in an app's Java code. A single InterstitialAd object can be used to request and display multiple interstitials over the course of an activity's lifespan, so you only need to construct it once.

Displaying the interstitial

...
mNewGameButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        } else {
            beginPlayingGame();
        }
    }
});
...

Here the new code checks to see if an interstitial ad has been loaded, and if so, displays it. If no ad is ready, the app goes straight into the next game.

Creating the AdListener

...
mInterstitialAd.setAdListener(new AdListener() {
    @Override
    public void onAdClosed() {
        requestNewInterstitial();
        beginPlayingGame();
    }
});
...

Here we're setting up an AdListener that includes a handler for the onAdClosed event, which is invoked when an interstitial is closed. The code above calls the requestNewInterstitial method to begin downloading a new ad, and starts a new game.

requestNewInterstitial

...
private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder()
              .addTestDevice("YOUR_DEVICE_HASH")
              .build();

    mInterstitialAd.loadAd(adRequest);
}
...

Here, an AdRequest.Builder object is used to create a simple request that is then passed into the InterstitialAd object's loadAd method, beginning the request process.

Note the use of the addTestDevice method during the creation of the request. It's important to make sure you always request test ads when developing and testing your applications. Testing with live, production ads is a violation of AdMob policy and can lead to suspension of your account. For more information on how to use test ads, see our Ad Targeting guide.

The result

Here is what the app looks like when an interstitial is shown.

The interstitial appears over the top of the application, giving the user the option to either close the ad (using the "X" in the upper-left corner) or tap anywhere else to be taken to the ad's destination URL.

Some best practices

Consider whether interstitials are the right type of ad for your application.
Interstitial ads work best in applications with natural transition points. The conclusion of a task within an application, like sharing an image or completing a game level, naturally creates such a point. Because the user is expecting a break in the action, it's easy to present an interstitial without disrupting their experience. Make sure you properly consider at which points in your app's workflow you'll display interstitials, and how the user is likely to respond.
Remember to pause the action when displaying an interstitial.
There are a number of different types of interstitial ads: text, image, video, and more. It's important to make sure that when your application displays an interstitial, it also suspends its use of some resources in order to allow the ad to take advantage of them. For example, when you make the call to display an interstitial, be sure to pause any audio output being produced by your app. You can resume playing sounds in the onAdClosed event handler, which will be invoked when the user has finished interacting with the ad. In addition, consider temporarily halting any intense computation tasks (such as a game loop) while the ad is being displayed. This will make sure the user doesn't experience janky graphics or stuttered video.
Allow for adequate loading time.
Just as it's important to make sure you display interstitials at an appropriate time, it's also important to make sure the user doesn't have to wait for them to load. By following the asynchronous loading pattern and calling loadAd before you intend to call show(), you can ensure that your application has a fully loaded interstitial at the ready when the time comes to display one.
Don't flood the user with ads.
While increasing the frequency of interstitials in your app might seem like a great way to increase revenue, it can also degrade the user experience and lower clickthrough rates. Make sure that users aren't so frequently interrupted that they're no longer able to enjoy the use of your application.

Further reading

For more information about the best way to integrate interstitial ads into your apps, check out AdMob's interstitial ad guidance.

You can also download our example app and see interstitial ads in action:

Download example from GitHub

FAQ

When I try to load a second interstitial, I see "An interstitial is already loading. Aborting." in my logs. What happened?
This warning appears when an app attempts to load a new interstitial before it's finished displaying the previous one. Make sure you're calling loadAd in the right place (we recommend the onAdClosed method of an AdListener).
When I call loadAd() on an InterstitialAd object I'm getting the message "Cannot present interstitial. It is not ready." What's going on?
This error means the interstitial ad was not successfully fetched. To prevent this warning from happening, use the isLoaded method to check if the interstitial is ready to present.
I'm not getting any ads back, and my log says "Request Error: No ads to show."
When creating an ad unit, make sure to specify "Interstitial" for the ad type. InterstitialAd objects only accepts ad units that are configured to serve interstitial ads.