# Interstitial

Interstitial is an ad type with full screen presentation, and it supports the static (image) and dynamic (video) content forms. Interstitial Format Example:

Images

Images

# Step 1: Set Up Interstitial Callback Listener

SDK will trigger a series of events to inform the app of Interstitial activities, such as Interstitial inventory status and Interstitial playback completion. Developers can know whether Interstitial is ready and clicked through events.Therefore, setting and implementing the interface method of Interstitial Callback Listener is a necessary operation to use Interstitial.The following code snippet demonstrates how to implement the InterstitialAdListener interface to receive and handle the Interstitial events.

All events triggered by Interstitial can be found in the following code.

InterstitialAd.setAdListener(new InterstitialAdListener() {

	/**
	 * Invoked when the interstitial ad availability status is changed.
	 *
	 * @param - available is a boolean. 
	 *	True: means the interstitial ad is available and you can 
	 *	show the video by calling InterstitialAd.showAd().
	 *	False: means no ad are available
	 */
	@Override
	public void onInterstitialAdAvailabilityChanged(boolean available) {
		// Change the interstitial ad state in app according to param available.
	}
	
	/**
	 * Invoked when the Interstitial ad view has opened.
	 * Your activity will lose focus.
	 */
	@Override
	public void onInterstitialAdShowed(Scene scene) {
		// Do not perform heavy tasks till the ad is going to be closed.
	}
	
	/**
	 * Invoked when the Interstitial ad is to be closed.
	 * Your activity will regain focus.
	 */
	@Override
	public void onInterstitialAdClosed(Scene scene) {
	}
	
	/**
	 * Invoked when the user clicked on the Interstitial ad.
	 */
	@Override
	public void onInterstitialAdClicked(Scene scene) {
	}
	
    /* Invoked when the call to load or show an Interstitial ad has failed 
     * @param - error contains the reason for the failure:
     */
    @Override
    public void onInterstitialAdShowFailed(Error error) {
       // Interstitial ad shows failed
   }

})

WARNING

Warning: The error parameter in the onInterstitialAdShowFailed callback contains the cause of failure. Please refer to Error Code.

# Step 2: Present Interstitial

Ads Availability Check

The intelligent inventory engine of Mint Mediation SDK is responsible for the maintenance of ads inventory. You only need to complete the SDK integration and initialization, and SDK will load ads automatically.The app will receive the event notification of change in ads availability by implementing the InterstitialAdListener interface, and obtain whether current ads are available through the available parameter of onInterstitialAdAvailabilityChanged interface.

public void onInterstitialAdAvailabilityChanged(boolean available)

Of course, you can directly call the isReady() method to check the ads inventory status as shown below.

public boolean InterstitialAd.isReady()

Present Ads

Once the true callback of onInterstitialoAvailabilityChanged  event is received, you can call the showAd() method to present ads.Of course, we do not propose to do so. The availability events occur only when the availability of ads changes. This does not necessarily conform to the ads scene designed by the app, and it may cause the frequent or even continuous ads presentation, which will cause trouble for users and affect the app experience.You shall select the ads presentation time according to the ads scene design in the app.

//if you would like to show ad right after it's was loaded
public void onInterstitialAdAvailabilityChanged(boolean available) {
	if(available) {
		InterstitialAd.showAd(scene)
   }
}

WARNING

Warning: The ads presentation in the onInterstitialAdAvailabilityChanged callback can lead to the unforeseen behavior.In general, you shall not do this except that it is in some specific scenes and the call of showAd method is restricted. If you want to present ads when needed (ads scene designed by app), we strongly recommend that you call the isReady() method to check whether the ads are available before presentation of ads as follows:

//if you would like to show ad when it's required
if (InterstitialAd.isReady()) {
  InterstitialAd.showAd(scene);
}

WARNING

Warning: When you complete Step 2 successfully, it means that the ads are presented successfully.If you want to present another ads, you just need to repeat Step 2 for presentation. You do not need to call the loadAd method to load ads manually.
If you aggregate the AdMob ads, you need to ensure that the isReady and showAd  methods are called in the main thread.

Finished!

Now, you can present Interstitial in the app.

# Up Next

You can aggregate other ad types based on our integration documents or test your integration: