Interstitial Integration

Interstitial ads provide full screen experiences, you can preload an interstitial ad and show it during the normal flow in your app. You can use the InstalInterstitial object and its associated listeners to fetch and display interstitial ads in your app.

Prerequisites

Before integrating interstitial ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project.

To have a banner you need to create an AdUnit setting the 'Dimensions' property to 'Mobile Banner Interstitial'.

Choosing mobile adunit dimension

Create and display an interstitial ad

The Instal SDK provides a custom class, InstalInterstitial, that handles fetching and displaying fullscreen interstitial ads. To ensure a smooth experience, you should prefetch the content as soon as your Activity is created, then display it whether you want.

In the Activity or in the Fragment in which you want to show the interstitial ad, declare a InstalInterstitial instance variable:

private InstalInterstitial interstitial;

InstalInterstitial provides a listener interface, InterstitialAdListener, which you’ll use to stay informed about ad lifecycle events.

In your Activity’s (or Fragment) onCreate() method, instantiate the InstalInterstitial using the context and the Ad Unit ID.

interstitial = new InstalInterstitial(this, "YOUR_ADUNIT_ID");

If you want to listen to interstitial events you can register a InterstitialAdListener:

interstitial.setInterstitialAdListener(new InterstitialAdListener() {
    @Override public void onInterstitialLoaded(InstalInterstitial interstitial) {
    }

    @Override public void onInterstitialFailed(InstalInterstitial interstitial, AdErrorCode errorCode) {
    }

    @Override public void onInterstitialShown(InstalInterstitial interstitial) {
    }

    @Override public void onInterstitialClicked(InstalInterstitial interstitial) {
    }

    @Override public void onInterstitialDismissed(InstalInterstitial interstitial) {
    }
});

Now you’re ready to display an interstitial. Displaying the ad takes two steps:

  1. load the interstitial (usually in onCreate method) using load method
  2. when you want to display the ad you can invoke show method

You can use isReady method to check if the interstitial is ready and can be shown. Lastly, remember to call destroy() on the interstitial in your Activity or Fragment onDestroy method.

A complete Activity code looks like this (showInterstitial method is binded to the click on a button):

public class InterstitialActivity extends Activity {

    private InstalInterstitial interstitial;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_interstitial);
        interstitial = new InstalInterstitial(this, "2");
        interstitial.load();
    }

    private void showToast(String s) {
        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
    }

    @Override protected void onDestroy() {
        super.onDestroy();
        interstitial.destroy();
    }

    public void showInterstitial(View view) {
        interstitial.show();
    }
}