> ## 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.

# Rewarded Video Ads

> Implement rewarded video ads in your Android app.

## Rewarded Video Ad Format

Provides in-app rewards (currency, features, content) in exchange for watching video ads. Videos are non-skippable and typically run 30 seconds.

![Rv Example Image Pn](https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/rv-example-image.png?fit=max\&auto=format\&n=j3-znW7LKrbpP3mb\&q=85\&s=05e99c43024f69661838e187b20caf06)

### How It Works

![Rv Example Gif Gi](https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/rv-example-gif.gif?s=d1b005af49b37b3c1306ef47728165bb)

***

## Integrating Ads

**1. Create adUnit**

```kotlin theme={null}
val adUnit = DaroRewardedAdUnit(
    key = ${AdUnitId},
    placement = ${placement}, //Name displayed in logs. Can be left empty.
)
```

**2. Create Loader and load ad**

```kotlin theme={null}
val loader = DaroRewardedAdLoader(
    context = context,
    adUnit = adUnit
)
loader.setListener(object : DaroRewardedAdLoaderListener {
    override fun onAdLoadSuccess(ad: DaroRewardedAd, adInfo: DaroAdInfo) {
        // ...
    }
    override fun onAdLoadFail(err: DaroAdLoadError) {
        // ...
    }
})
loader.load()
```

**3. Set listener and show ad**

```kotlin theme={null}
loader.setListener(object : DaroRewardedAdLoaderListener {
    override fun onAdLoadSuccess(ad: DaroRewardedAd, adInfo: DaroAdInfo) {
        ad.setListener(object : DaroRewardedAdListener {
            override fun onShown(adInfo: DaroAdInfo) {}
            override fun onFailedToShow(adInfo: DaroAdInfo, error: DaroAdDisplayFailError) {}
            override fun onDismiss(adInfo: DaroAdInfo) {}
            override fun onEarnedReward(adInfo: DaroAdInfo, rewardItem: DaroRewardedAd.DaroRewardedItem) {}
        })
        ad.show(activity = this@MainActivity)
    }
    override fun onAdLoadFail(err: DaroAdLoadError) {}
})
```

**4. Call destroy after ad viewing is complete**

```kotlin theme={null}
ad.destroy()
```

> [!NOTE]
>
> You can set the server callback method as follows:
>
> ```kotlin {4,5} theme={null}
>   loader.setListener(object : DaroRewardedAdLoaderListener {
>       override fun onAdLoadSuccess(ad: DaroRewardedAd, adInfo: DaroAdInfo) {
>           ...
>           Daro.setUserId(context = context, ${user_id})
>           ad.setCustomData(${custom_data})
>           ...
>       }
>       ...
>   })
> ```

***

## Example

```kotlin expandable theme={null}
private fun showRewardAd() {
    DaroRewardedAdLoader(
      context = context,
      adUnit = DaroRewardedAdUnit(
        key = ${AdUnitId},
        placement = ${placement}
      )
    ).apply {
      setListener(
        object : DaroRewardedAdLoaderListener {
          override fun onAdLoadSuccess(ad: DaroRewardedAd, adInfo: DaroAdInfo) {
            Log.d("Ad Test", "rewarded - success")

            ad.setListener(
              object : DaroRewardedAdListener {
                override fun onShown(adInfo: DaroAdInfo) {
                  Log.d("Ad Test", "rewarded - onShown")
                }

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

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

                override fun onEarnedReward(
                  adInfo: DaroAdInfo,
                  rewardItem: DaroRewardedAd.DaroRewardedItem,
                ) {
                  Log.d("Ad Test", "rewarded - onEarnedReward")
                }
              },
            )

            Daro.setUserId(context = context, ${user_id})
            ad.setCustomData(${custom_data})

            ad.show(activity = this@MainActivity)
          }
        })
      load()
    }
  }
```

***

## Troubleshooting: Ad Close Button Overlap Issue

> [!WARNING]
>
> When displaying rewarded video 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.

```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 : DaroRewardedAdListener {
    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()
    }
    override fun onEarnedReward(adInfo: DaroAdInfo, rewardItem: DaroRewardedAd.DaroRewardedItem) {}
})

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.