Interstitial Ads

Interstitial ads use a full-screen experience that is typically shown during natural transition points in your app - for example between levels of a game, or while waiting for new content to load. MobileFuse offers both rich media and video interstitial ads, and the SDK will automatically choose the highest performing ad available for display.

Prerequisites

Display an interstitial ad in your app

Displaying an interstitial ad is a two-step process. First you should create and load your MobileFuseInterstitialAd unit, then when you’re ready, call the showAd() method to display the ad.

  1. Create an interstitial ad unit
  2. Display the ad

Create an interstitial ad unit

The MobileFuseInterstitialAd class provided by the MobileFuse SDK will handle the loading and display of the full-screen ads.

📘

Tip

To provide a good user experience, you should create and pre-load your interstitial ad units as soon as your app is launched. Once an interstitial ad unit is created and pre-loaded, you can display it instantly with the showAd() method. Having the ad preloaded will ensure that you’re ready to display the ad as soon as the interstitial opportunity occurs. However, please note that ads expire after 5 minutes (at which time you’ll need to request a new one), so plan accordingly.

First, create a new MobileFuseInterstitalAd unit and keep a reference to it within the Activity that you want to use it:

private MobileFuseInterstitialAd interstitial;

private void createInterstitialAd() {
    String placementId = "000000";
    interstitial = new MobileFuseInterstitialAd(this, placementId);
}
private var interstitial: MobileFuseInterstitialAd? = null

private fun createInterstitialAd() {
    val placementId = "000000"
    interstitial = MobileFuseInterstitialAd(this, placementId)
}

📘

Note

Ensure that the SDK has fully initialized before creating your ad units. You can use the onInitSuccess callback as a good place to set up your ad units.

Next, add a listener - the listener will allow you to receive events from the ad unit.

interstitial.setListener(new MobileFuseInterstitialAd.Listener() {
    @Override
    public void onAdLoaded() {
        // Ad has loaded - you are able to show the ad after this callback is triggered
    }

    @Override
    public void onAdNotFilled() {
        // No ad is currently available to display to this user
    }

    @Override
    public void onAdClosed() {
        // The ad has been displayed and closed
    }

    @Override
    public void onAdRendered() {
        // Triggered when the ad begins to show to the user
    }

    @Override
    public void onAdClicked() {
        // Triggered when the ad is clicked by the user
    }

    @Override
    public void onAdExpired() {
        // Triggered when a loaded ad has expired - you should manually try to load a new ad here
    }

    @Override
    public void onAdError(AdError error) {
        // An error occurred with the ad, examine the `error` argument to determine what went wrong
    }
});
interstitial.setListener(object : MobileFuseInterstitialAd.Listener {
    override fun onAdLoaded() {
        // Ad has loaded - you are able to show the ad after this callback is triggered
    }

    override fun onAdNotFilled() {
        // No ad is currently available to display to this user
    }

    override fun onAdClosed() {
        // The ad has been displayed and closed
    }

    override fun onAdRendered() {
        // Triggered when the ad begins to show to the user
    }

    override fun onAdClicked() {
        // Triggered when the ad is clicked by the user
    }

    override fun onAdExpired() {
        // Triggered when a loaded ad has expired - you should manually try to load a new ad here
    }

    override fun onAdError(error: AdError) {
        // An error occurred with the ad, examine the `error` argument to determine what went wrong
    }
})

Finally, request that the ad is preloaded using the loadAd method:

interstitial.loadAd();
interstitial.loadAd()

Display the ad

Once the interstitial ad has triggered the onAdLoaded callback, you can then call showAd() to instantly display the ad:

interstitial.showAd();
interstitial.showAd()

You can also use isLoaded() to check whether the ad is ready to be displayed.

if (interstitial.isLoaded()) {
    // The ad is ready to be displayed!
}
if (interstitial.isLoaded) {
    // The ad is ready to be displayed!
}

📘

Note

Once you call showAd() on an instance, the loaded ad will be displayed. Since a loaded ad can only be displayed once, you must call loadAd() again once the ad is closed to get a new ad ready to display.

Sample Code