# Interstitial Ads

## What are Interstitial Ads? <a href="#bannerads6.0.0-initializeinitializeabannerview" id="bannerads6.0.0-initializeinitializeabannerview"></a>

Interstitial Ad Units are full-screen, interactive ads designed to be placed between content at a natural transition point.

## How to Display Interstitial Ads <a href="#bannerads6.0.0-initializeinitializeabannerview" id="bannerads6.0.0-initializeinitializeabannerview"></a>

### Integrate & Initialize HyprMX <a href="#bannerads6.0.0-initializeinitializeabannerview" id="bannerads6.0.0-initializeinitializeabannerview"></a>

Before you start, make sure you have correctly integrated and initialized the HyprMX SDK. To integrate and initialize HyprMX, see our [Setup Guide](/sdk-integration-guides/android-amazon.md).

### Loading Interstitial Ads <a href="#quickstart-loading_adsloadinganddisplayingadvertisements" id="quickstart-loading_adsloadinganddisplayingadvertisements"></a>

HyprMX utilizes placements to load and display an ad. Placements are used to represent a point in your application's workflow where you'd like to show an ad. To load an ad to a placement, follow the steps below.

{% hint style="info" %}
If you don't have your placement information, please reach out to your account manager to configure your interstitial placements. In return, they will provide the names of the new placements.
{% endhint %}

{% stepper %}
{% step %}
Use the `getPlacement` API to retrieve a placement from HyprMX.

{% tabs %}
{% tab title="Java" %}

```java
interstitialPlacement = HyprMX.INSTANCE.getPlacement("YOUR_INTERSTITIAL_PLACEMENT_NAME");
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
interstitialPlacement = HyprMX.getPlacement("YOUR_INTERSTITIAL_PLACEMENT_NAME")
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}
To check for availability, run the following:

{% tabs %}
{% tab title="Java" %}

```java
interstitialPlacement.loadAd(new HyprMXLoadAdListener() {
  @Override
  public void onAdLoaded(boolean isAdAvailable) {
    if(isAdAvailable) {
      // You can show the ad
   }
  }
});
```

{% endtab %}

{% tab title="Java (Lambda)" %}

```java
interstitialPlacement.loadAd(isAdAvailable -> {
   if(isAdAvailable) {
      // You can show the ad
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
interstitialPlacement.loadAd { isAdAvailable ->
   if(isAdAvailable) {
      // You can show the ad
   }
}
```

{% endtab %}

{% tab title="Kotlin (Coroutines)" %}

```kotlin
val isAdAvailable = interstitialPlacement.loadAd()

if(isAdAvailable) {
    // You can show the ad
}
```

{% endtab %}
{% endtabs %}

loadAd() will call back to your `listener` with: `isAdAvailable == true` when an ad is available or `false` when there is no inventory.
{% endstep %}

{% step %}
To receive notification that the loaded ad has expired, implement the `HyprMXPlacementExpiryListener`

{% tabs %}
{% tab title="Java" %}

```java
private HyprMXPlacementExpiryListener listener = new HyprMXPlacementExpiryListener() {
  @Override
  public void onAdExpired(@NonNull Placement placement) {
      // Do something on expiration
  }
}

interstitialPlacement.setPlacementExpiryListener(listener);
```

{% endtab %}

{% tab title="Java (Lambda)" %}

```java
interstitialPlacement.setPlacementExpiryListener(placement -> {
   // Do something on expiration
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val listener = object : HyprMXPlacementExpiryListener {
    override fun onAdExpired(placement: Placement) {
       // Do something on expiration
    }
}

interstitialPlacement.setPlacementExpiryListener(listener)
```

{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

### Displaying Interstitial Ads <a href="#quickstart-loading_adsloadinganddisplayingadvertisements" id="quickstart-loading_adsloadinganddisplayingadvertisements"></a>

{% stepper %}
{% step %}
Before calling `showAd` on a placement, you should confirm the ad state is still valid:

{% tabs %}
{% tab title="Java" %}

```java
interstitialPlacement.isAdAvailable();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
interstitialPlacement.isAdAvailable()
```

{% endtab %}
{% endtabs %}

When an ad is displaying, it is important to disable all in-game music and sounds so they do not interfere with the advertisements. You can disable them when your activity transitions to `onStop` and resume when your activity transitions to `onResume`.
{% endstep %}

{% step %}
When you are ready to display an ad, call `showAd` to begin the presentation of an ad.

{% tabs %}
{% tab title="Java" %}

```java
if (interstitialPlacement.isAdAvailable()) {
  interstitialPlacement.showAd(this);
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
if (interstitialPlacement.isAdAvailable()) {
  interstitialPlacement.showAd(this)
}
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}
To receive display status, implement the `HyprMXShowListener`:

{% tabs %}
{% tab title="Java" %}

```java
/**
 * Called when an ad is shown for the given placement. Your application should pause here.
 */
@Override
public void onAdStarted(Placement placement) {}

/**
 * Called when an ad is closed. Your application should resume here.
 */
@Override
public void onAdClosed(Placement placement, boolean finished) {}

/**
 * Called when there was an error displaying the ad.
 */
@Override
public void onAdDisplayError(Placement placement, HyprMXErrors hyprMXError) {}

/**
 * Called when the ad was impressed.
 */
@Override
public void onAdImpression(Placement placement) {}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/**
 * Called when an ad is shown for the given placement. Your application should pause here.
 */
override fun onAdStarted(placement: Placement) {}

/**
 * Called when an ad is closed. Your application should resume here.
 */
override fun onAdClosed(placement: Placement, finished: Boolean) {}

/**
 * Called when there was an error displaying the ad.
 */
override fun onAdDisplayError(placement: Placement, hyprMXError: HyprMXErrors) {}

/**
 * Called when the ad was impressed.
 */
override fun onAdImpression(placement: Placement) {}
```

{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

If you'd like, we can send server-to-server calls when ads are completed. Contact your account manager at HyprMX for more details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.hyprmx.com/sdk-integration-guides/android-amazon/ad-formats/interstitial-ads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
