# Android > Integration guides > Interstitial

Source: https://help-display-sdk.equativ.com/android/integration/interstitial.html

This page explains how to use the **Equativ Display SDK** to display an interstitial ad in your application.

---

## Overview

Interstitials are loaded and displayed using a [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) instance.

To load and display an interstitial ad you need:
- A fully configured **Equativ Display SDK**
- An instance of [`SASAdPlacement`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.model/-s-a-s-ad-placement/index.html) that will be used to perform ad calls to the delivery engine.
- An instance of [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) to load an ad for the specified placement and show the interstitial if an ad was successfully loaded.
- An object implementing the [`SASInterstitialManager.InterstitialManagerListener`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/index.html) listener to monitor interstitial ads lifecycle events.

The next sections describe in details how to load and show an interstitial ad.

You can also refer to the [samples](https://github.com/smartadserver/equativ-display-sdk-samples-android) if you need a full runnable project.

## Configuring the SDK

The **Equativ Display SDK** needs to be configured before making any ad calls. You will have to call the method [`configure()`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.util/-s-a-s-configuration/configure.html) of the [`SASConfiguration`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.util/-s-a-s-configuration/index.html) shared instance to do so.

This method must be called once, as soon as possible.

Ideally call it in the `onCreate()` method of your `Application` class. For instance:

```kotlin
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        // Configure Equativ Display SDK
        SASConfiguration.configure(this)
    }
}
```

Any ad call performed before calling the [`configure()`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.util/-s-a-s-configuration/configure.html) method will fail by throwing an `IllegalStateException`.

## Creating a placement

You will need an _ad placement_ to perform an ad call. A placement identifies a part of your inventory where you want to display ads.

Creating an ad placement is done by instantiating a [`SASAdPlacement`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.model/-s-a-s-ad-placement/index.html) object using mandatory parameters _site ID_, _page ID_, _format ID_ and an optional _keyword targeting_ String (more info [in the API documentation](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.model/-s-a-s-ad-placement/index.html)).

```kotlin
val adPlacement = SASAdPlacement(SITE_ID, PAGE_ID, FORMAT_ID, OPTIONAL_KEYWORD_TARGETING)
```

> You can add several information to your _ad placements_ in order to **increase the monetization**.
>
> For instance you can provide a [_Seller Defined Audience_](https://help-display-sdk.equativ.com/sellerdefinedaudience.html.md) object, or a [_Supply Chain Object_](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.model/-s-a-s-ad-placement/supply-chain-object-string.html) if your are an inventory reseller.

Note that for testing purposes, it is possible to instantiate a generic ad placement that will always deliver an ad from a particular type.
You will find more information on the dedicated section [here](https://help-display-sdk.equativ.com/android/troubleshooting.html#test).

Don't forget to remove all test placements before releasing your app!

## Loading an interstitial using a manager

Interstitial ads are handled using an _interstitial manager_ which enables a two steps process: **load the ad** then **show it at your convenience**.

The interstitial manager is also attached to a unique placement object passed at instantiation time.

The separation of the load and show steps also means that setting a [`SASInterstitialManager.InterstitialManagerListener`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/index.html) on the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) instance
is **mandatory** (contrary to banner integration).

To load an interstitial, start by creating a new [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) instance using the current application Activity, the _ad placement_ defined earlier and an Object implementing the [`SASInterstitialManager.InterstitialManagerListener`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/index.html) interface:

```kotlin
// Creation of the SASInterstitialManager
val interstitialManager = SASInterstitialManager(activity, adPlacement)

// Creation and setup of the InterstitialManagerListener
interstitialManager.interstitialManagerListener = object : SASInterstitialManager.InterstitialManagerListener {
    override fun onInterstitialAdLoaded(adInfo: SASAdInfo) {
        Log.i("Sample", "Interstitial loading completed");
    }

    override fun onInterstitialAdFailedToLoad(exception: Exception) {
        Log.i("Sample", "Interstitial loading has failed with exception: $exception");
    }

    override fun onInterstitialAdShown() {
        Log.i("Sample", "Interstitial was shown");
    }

    override fun onInterstitialAdFailedToShow(exception: Exception) {
        Log.i("Sample", "Interstitial has failed to show with exception: $exception");
    }

    override fun onInterstitialAdClosed() {
        Log.i("Sample", "Interstitial was closed");
    }

    override fun onInterstitialAdClicked() {
        Log.i("Sample", "Interstitial was clicked");
    }
}
```

There are methods of the listener interface that you can leave empty, but you should at least implement the two
methods [`onInterstitialAdLoaded`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/on-interstitial-ad-loaded.html) and [`onInterstitialAdFailedToLoad`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/on-interstitial-ad-failed-to-load.html) used to check if an interstitial
ad has been loaded or if it has failed to load.

This will notify you if the interstitial can be shown or if you need to try another load ad call.

Finally, to actually trigger the interstitial ad loading process, call the [`loadAd`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/load-ad.html) method of the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html):

```kotlin
interstitialManager.loadAd()
```

The [`loadAd`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/load-ad.html) method of the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) executes the ad loading task asynchronously in a different
thread from the calling thread. Therefore, if the [`loadAd`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/load-ad.html) method is called while a previous ad call is being performed
and has not finished yet, it will fail with a [`SASException`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.exception/-s-a-s-exception/index.html) of type `PENDING_AD_LOADING`
in the [`onInterstitialAdFailedToLoad`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/on-interstitial-ad-failed-to-load.html) method of the [`SASInterstitialManager.InterstitialManagerListener`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/index.html).

## Showing an interstitial

When the interstitial manager has successfully loaded an ad, you can show it when needed using the [`show`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/show.html) method.

It is also possible to check the current status of an interstitial manager at any time using the [`getAdStatus`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/get-ad-status.html) getter,
giving you the current [`SASAdStatus`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.model/-s-a-s-ad-status/index.html) of the intersitial manager.

```kotlin
if (interstitialManager.getAdStatus() == SASAdStatus.READY) {
    interstitialManager.show()
} else {
    // The interstitial manager's ad is either still loading, or not available. 
}
```

Note that the [`show`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/show.html) method can fail and trigger the [`onInterstitialAdFailedToShow`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/on-interstitial-ad-failed-to-show.html) method, providing details about the error in the `Exception` parameter.

When an interstitial ad has been shown, it is discarded and **a new one must be loaded again**. The current _interstitial manager_ instance can be reused if the _ad placement_ remains the same.

## Listening to ad audio events

You can listen to ad audio events (as well as other interstitial manager events) by implementing the [`SASInterstitialManager.InterstitialManagerListener`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/-interstitial-manager-listener/index.html) interface on the interstitial manager.

```kotlin
interstitialManager.interstitialManagerListener = object : SASInterstitialManager.InterstitialManagerListener {
    override fun onInterstitialAdAudioStart() {
        Log.i(TAG, "Interstitial video ad will start to play audio")

        // Equativ Display SDK is notifying your app that it will play audio.
        // You could optionally pause music depending on your apps design.
    }

    override fun onInterstitialAdAudioStop() {
        Log.i(TAG, "Interstitial video ad did stop to play audio")

        // Equativ Display SDK is notifying your app that it has stopped playing audio.
        // Depending on your apps design, you could resume music here.
    }
}
```

> All video ads start muted and require user interaction to toggle audio.

## Disposing of an interstitial manager

Once you are done using an interstitial manager, typically when its hosting `Activity` is being destroyed, you must call
the [`onDestroy`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/on-destroy.html) method of the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/android/API/-display%20-s-d-k/com.equativ.displaysdk.ad.interstitial/-s-a-s-interstitial-manager/index.html) to release the resources it was using.

```kotlin
/**
* Overriden from Activity class
*/
override fun onDestroy() {
    super.onDestroy();
    interstitialManager.interstitialManagerListener = null
    interstitialManager.onDestroy()
}
```
