> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/android-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aatkit.gitbook.io/android-integration/formats/rewarded-video.md).

# Rewarded Video

In general, rewarded videos are similar to fullscreen ads in the aspect that it covers the whole screen of the device. What rewarded video ads add is the ability to reward the user when he watches the videos.

### Create Placement <a href="#create-placement" id="create-placement"></a>

To create an instance of [RewardedVideoPlacement](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-rewarded-video-placement/index.html), use the following API:

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

```java
RewardedVideoPlacement placement = AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>");
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val placement = AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>")
```

{% endtab %}
{% endtabs %}

### Listen to Callbacks (Optional) <a href="#listen-to-callbacks-optional" id="listen-to-callbacks-optional"></a>

Through the use of [RewardedVideoPlacementListener](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-rewarded-video-placement-listener/index.html), you can listen to the different placement callbacks.

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

```java
placement.setListener(this);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
placement.listener = this
```

{% endtab %}
{% endtabs %}

#### AATKitReward

When the user is rewarded while watching a rewarded video, the placement will notify you through its delegate method: `onUserEarnedIncentive` passing itself and an [AATKitReward](https://gravite-sdk-releases.s3.eu-central-1.amazonaws.com/aatkit/android/docs/-a-a-t-kit/com.intentsoftware.addapptr/-a-a-t-kit-reward/index.html) instance.

### Request Ad

You can load ads for the rewarded video placement either automatically or manually.

#### Automatic Reload <a href="#automatic-reload" id="automatic-reload"></a>

To automatically load rewarded video Placement:

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

```java
placement.startAutoReload();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
placement.startAutoReload()
```

{% endtab %}
{% endtabs %}

This way the rewarded video placement will always try to have an ad ready. Please also remember to stop the auto-reload when it is no longer needed:

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

```java
placement.stopAutoReload();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
placement.stopAutoReload()
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The rewarded video placement fires the `onHaveAd` listener method only once per loaded ad. So, Before starting the auto-reload, you should check for ads from the previous load/auto-reload using the placement [has ad](#has-ad) API.
{% endhint %}

#### Manual Load <a href="#manual-load" id="manual-load"></a>

To manually load the rewarded video placement:

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

```java
placement.reload();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
placement.reload()
```

{% endtab %}
{% endtabs %}

### Ad Info <a href="#a-d-info" id="a-d-info"></a>

After loading a rewarded video, you can access the loaded ad information by accessing the adInfo property of the fullscreen placement:

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

```java
AdInfo adInfo = placement.getAdInfo();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val info = placement.adInfo
```

{% endtab %}
{% endtabs %}

### Mute Ad <a href="#display-a-d" id="display-a-d"></a>

Some ad networks allow muting rewarded video ads. Use the following API to mute video ads:

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

```java
AATKit.muteVideoAds(true);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
AATKit.muteVideoAds(true)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Currently only AdMob, DFP, AppLovin, Mintegral and GraviteRTB support this feature.
{% endhint %}

### Display Ad <a href="#display-a-d" id="display-a-d"></a>

the AATKit can be told to display a rewarded video placement using the following method:

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

```java
placement.show();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
placement.show()
```

{% endtab %}
{% endtabs %}

The `show()` method will return a bool value indicating whether the rewarded video placement could be displayed or not. This means whether the rewarded video placement has a ready-rewarded video ad or not.

### Has Ad

The rewarded video placement provides an API to check if it has a loaded ad.

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

```java
boolean hasAd = placement.hasAd();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val hasAd = placement.hasAd()
```

{% endtab %}
{% endtabs %}

### Complete Code Example <a href="#complete-code-example" id="complete-code-example"></a>

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

```java
 private RewardedVideoPlacement placement = AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>");

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Set placement listener to listen to the callbacks
    placement.setListener(this);
    // Start autoreloading the placement.
    placement.startAutoReload();
}

@Override
protected void onPause() {
    // [IMPORTANT] Stop placement autoreload
    placement.stopAutoReload();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this);
    super.onPause();
}

private void watchVideo() {
    // An example for showing the rewarded video ad when the user clicks on "watch Video" button.
    if (!placement.show()) {
        // Show a message to the user telling: "Currently, no video available. Please try again later."
    }
}

// RewardedVideoPlacementListener
@Override
public void onPauseForAd(@NonNull Placement placement) {
    // Ad has been displayed on the screen
}

@Override
public void onResumeAfterAd(@NonNull Placement placement) {
    // Back to the app
}

@Override
public void onHaveAd(@NonNull Placement placement) {
    // The placement has loaded a new ad
}

@Override
public void onNoAd(@NonNull Placement placement) {
    // The placement could not load a new ad
}

@Override
public void onUserEarnedIncentive(@NonNull Placement placement, @Nullable AATKitReward aatKitReward) {
    // The user has earned an incentive for this placement.
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
private val placement = createRewardedVideoPlacement("<PLACEMENT_NAME>")

override fun onResume() {
    super.onResume()
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this)

    // Set placement listener to listen to the callbacks
    placement?.listener = this
    // Start autoreloading the placement.
    placement?.startAutoReload()
}

override fun onPause() {
    // [IMPORTANT] Stop placement autoreload
    placement?.stopAutoReload()
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this)
    super.onPause()
}

private fun watchVideo() {
    // An example for showing the rewarded video ad when the user clicks on "watch Video" button.
    if (placement?.show() == false) {
        // Show a message to the user telling: "Currently, no video available. Please try again later."
    }
}

// RewardedVideoPlacementListener
override fun onPauseForAd(placement: Placement) {
    // Ad has been displayed on the screen
}

override fun onResumeAfterAd(placement: Placement) {
    // Back to the app
}

override fun onHaveAd(placement: Placement) {
    // The placement has loaded a new ad
}

override fun onNoAd(placement: Placement) {
    // The placement could not load a new ad
}

override fun onUserEarnedIncentive(placement: Placement, aatKitReward: AATKitReward?) {
    // The user has earned an incentive for this placement.
}
```

{% endtab %}
{% endtabs %}
