> ## Documentation Index
> Fetch the complete documentation index at: https://guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Interstitial Ads

> Implement interstitial ads in your Android app.

## Interstitial Ad Format

Full-screen ads that cover the entire app interface. Includes both image and video ads (video more common), typically skippable after 5 seconds.

<img src="https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/interstitial-example-image.png?fit=max&auto=format&n=j3-znW7LKrbpP3mb&q=85&s=7404e29ead548d55d8d587336f8721f9" alt="Interstitial Example Image Pn" title="Interstitial Example Image Pn" style={{ width:"40%" }} width="1080" height="2336" data-path="sdk-integration/common-img/ad-formats-en/interstitial-example-image.png" />

### How It Works

<img src="https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/interstitial-example-gif.gif?s=9f37cff5b366f1e05211b0d177b3926b" alt="Interstitial Example Gif Gi" title="Interstitial Example Gif Gi" style={{ width:"40%" }} width="240" height="518" data-path="sdk-integration/common-img/ad-formats-en/interstitial-example-gif.gif" />

***

## Integrating Ads

<Steps>
  <Step title="Create adUnit">
    ```kotlin theme={null}
    val adUnit = DaroInterstitialAdUnit(
        key = ${AdUnitId},
        placement = ${placement}, // Name displayed in logs. Can be left empty.
    )
    ```
  </Step>

  <Step title="Create Loader and load ad">
    ```kotlin theme={null}
    val loader = DaroInterstitialAdLoader(
        context = context,
        adUnit = adUnit
    )
    loader.setListener(object : DaroInterstitialAdLoaderListener {
        override fun onAdLoadSuccess(ad: DaroInterstitialAd, adInfo: DaroAdInfo) {
            // ...
        }
        override fun onAdLoadFail(err: DaroAdLoadError) {
            // ...
        }
    })
    loader.load()
    ```
  </Step>

  <Step title="Set listener and show ad">
    ```kotlin theme={null}
    loader.setListener(object : DaroInterstitialAdLoaderListener {
        override fun onAdLoadSuccess(ad: DaroInterstitialAd, adInfo: DaroAdInfo) {
            ad.setListener(object : DaroInterstitialAdListener {
                override fun onAdImpression(adInfo: DaroAdInfo) {}
                override fun onAdClicked(adInfo: DaroAdInfo) {}
                override fun onShown(adInfo: DaroAdInfo) {}
                override fun onFailedToShow(adInfo: DaroAdInfo, error: DaroAdDisplayFailError) {}
                override fun onDismiss(adInfo: DaroAdInfo) {}
            })
            ad.show(activity = this@MainActivity)
        }
        override fun onAdLoadFail(err: DaroAdLoadError) {}
    })
    ```
  </Step>

  <Step title="Call destroy after ad viewing is complete">
    ```kotlin theme={null}
    ad.destroy()
    ```
  </Step>
</Steps>

***

## Example

```kotlin expandable theme={null}
private fun showInterstitialAd() {
  DaroInterstitialAdLoader(
    context = context,
    adUnit = DaroInterstitialAdUnit(
      key = ${AdUnitId},
      placement = ${placement},
    ),
  ).apply {
    setListener(
      object : DaroInterstitialAdLoaderListener {
        override fun onAdLoadSuccess(
          ad: DaroInterstitialAd,
          adInfo: DaroAdInfo,
        ) {
          Log.d("Ad Test", "interstitial - success")

          ad.setListener(object : DaroInterstitialAdListener {
            override fun onAdImpression(adInfo: DaroAdInfo) {
              Log.d("Ad Test", "interstitial - impression")
            }

            override fun onAdClicked(adInfo: DaroAdInfo) {
              Log.d("Ad Test", "interstitial - clicked")
            }

            override fun onShown(adInfo: DaroAdInfo) {
              Log.d("Ad Test", "interstitial - onShown")
            }

            override fun onFailedToShow(
              adInfo: DaroAdInfo,
              error: DaroAdDisplayFailError,
            ) {
              Log.d("Ad Test", "interstitial - onFailedToShow")
            }

            override fun onDismiss(adInfo: DaroAdInfo) {
              Log.d("Ad Test", "interstitial - onDismiss")
              ad.destroy()
            }
          })

          ad.show(activity = this@MainActivity)
        }

        override fun onAdLoadFail(err: DaroAdLoadError) {
          Log.d("Ad Test", "interstitial - fail : ${err.message}")
        }

      }
    )
    load()
  }
}
```

***

## Troubleshooting: Ad Close Button Overlap Issue

<Warning>
  When displaying interstitial ads using the DARO Android SDK, some ad creatives may visually overlap with the Status Bar or display cutout (notch, punch-hole) area.
  The following guide shows how to hide the Status Bar only while the ad is displayed and restore it once the ad is dismissed.
</Warning>

```kotlin theme={null}
// Before showing ad - hide status bar
private fun hideStatusBar(activity: Activity) {
    WindowCompat.setDecorFitsSystemWindows(activity.window, false)
    WindowInsetsControllerCompat(activity.window, activity.window.decorView).apply {
        hide(WindowInsetsCompat.Type.statusBars())
        systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
    }
}

// After ad closes - restore status bar
private fun showStatusBar(activity: Activity) {
    WindowCompat.setDecorFitsSystemWindows(activity.window, true)
    WindowInsetsControllerCompat(activity.window, activity.window.decorView).apply {
        show(WindowInsetsCompat.Type.statusBars())
    }
}
```

Apply it in the ad listener as follows:

```kotlin theme={null}
ad.setListener(object : DaroInterstitialAdListener {
    override fun onAdImpression(adInfo: DaroAdInfo) {}
    override fun onAdClicked(adInfo: DaroAdInfo) {}
    override fun onShown(adInfo: DaroAdInfo) {
        hideStatusBar(activity)  // Defensive re-hide
    }
    override fun onFailedToShow(adInfo: DaroAdInfo, error: DaroAdDisplayFailError) {
        showStatusBar(activity)  // Restore on failure
    }
    override fun onDismiss(adInfo: DaroAdInfo) {
        showStatusBar(activity)  // Restore on dismiss
        ad.destroy()
    }
})

hideStatusBar(activity)  // Call just before show()
ad.show(activity = this@MainActivity)
```
