Interstitial Ads

Interstitial Ads are full screen ads that display over any of your application’s content. These ads often result in higher eCPM for developers. The best time to use Interstitial Ads is during a natural break in the application’s content, such as after completion of a level in a game.

Within interstitial ad placements developers have the option to display interactive video ads. These units often produce the highest eCPM. To ensure a placement is able to recieve these ads, check mMedia or speak to a Millennial Media Account Manager.

Basic Integration

NOTE: Items in source like <YOUR_PLACEMENT_ID> must be replaced with your information.

1. Create the interstitial placement instance and set the listeners.
import com.millennialmedia.InterstitialAd;
import com.millennialmedia.MMException;


try {
    final InterstitialAd interstitialAd = InterstitialAd.createInstance(<YOUR_PLACEMENT_ID>);

    interstitialAd.setListener(new InterstitialAd.InterstitialListener() {
        @Override
        public void onLoaded(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad loaded.");
        }


        @Override
        public void onLoadFailed(InterstitialAd interstitialAd,
           InterstitialAd.InterstitialErrorStatus errorStatus) {

            Log.i(TAG, "Interstitial Ad load failed.");
        }


        @Override
        public void onShown(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad shown.");
        }


        @Override
        public void onShowFailed(InterstitialAd interstitialAd,
            InterstitialAd.InterstitialErrorStatus errorStatus) {

            Log.i(TAG, "Interstitial Ad show failed.");
        }


        @Override
        public void onClosed(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad closed.");
        }


        @Override
        public void onClicked(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad clicked.");
        }


        @Override
        public void onAdLeftApplication(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad left application.");
        }


        @Override
        public void onExpired(InterstitialAd interstitialAd) {

            Log.i(TAG, "Interstitial Ad expired.");
        }
  });

} catch (MMException e) {
    Log.e(TAG, "Error creating interstitial ad", e);
    // abort loading ad
}
2. Load the ad from the server.

When calling load, the activity argument should be the current activity when the load call is invoked. The return value from the createInstance call is an interface for the ad placement rather than an actual view.

if (interstitialAd != null) {
    interstitialAd.load(getActivity(), null);
}
3. Check that the ad is ready and display the ad.
// Check that the ad is ready.
if (interstitialAd.isReady()) {
	// Show the Ad using the display options you configured.
	try {
		interstitialAd.show(getActivity());
	} catch (MMException e) {
		Log.i(TAG, "Unable to show interstitial ad content, exception occurred");
		e.printStackTrace();
	}
	
} else {
	Log.w(TAG, "Unable to show interstitial. Ad not loaded.");
}

Best Practice: Interstitial ads are cached to the user’s device in order to provide the best possible experience. It is recommended that publishers request interstitial ads at least 10-30 seconds before they are ready to be displayed. This helps ensure that the ad is fully cached and ready to display.