> For the complete documentation index, see [llms.txt](https://docs.digitalturbine.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalturbine.com/dt-exchange/sdk-configuration/integrating-the-android-sdk/android-ad-formats/rewarded-ads.md).

# Rewarded Ads

Rewarded ads are full-screen, video or interactive ads that offer users an in-app reward (like extra lives, in-game currency, or exclusive content) for watching the complete ad.

## Building the Ad Placement (Ad Spot) <a href="#h_01hvkbkvnetmv9cvpvp949vxv9" id="h_01hvkbkvnetmv9cvpvp949vxv9"></a>

Add the required controllers to set up the ad placement:

{% code title="Java" %}

```java
// Spot integration for Rewarded Ads
InneractiveAdSpot mSpot = InneractiveAdSpotManager.get().createSpot();

// Adding the adview controller
InneractiveFullscreenUnitController controller = new InneractiveFullscreenUnitController();

// Adding the Video adview controller
InneractiveFullscreenVideoContentController videoContentController = new InneractiveFullscreenVideoContentController();

controller.addContentController(videoContentController);

mSpot.addUnitController(controller);
```

{% endcode %}

## Adding Listeners <a href="#h_01hvkbkvnepav23dd5m3gmx4n5" id="h_01hvkbkvnepav23dd5m3gmx4n5"></a>

Add listeners for the controller and the spot.

### Adding Event Listener for the Controller <a href="#id-01k7bx3d1jynmta7vvce1286rx" id="id-01k7bx3d1jynmta7vvce1286rx"></a>

The examples below demonstrate how you would add an `EventListener` to receive rewarded ad callbacks:

#### Events: <a href="#h_01k83r5g56k6ewhhv14gtmgqbh" id="h_01k83r5g56k6ewhhv14gtmgqbh"></a>

{% code title="Java" %}

```java
controller.setEventsListener(new InneractiveFullscreenAdEventsListener() {
    @Override
    public void onAdImpression(InneractiveAdSpot inneractiveAdSpot) {
    }
    @Override
    public void onAdClicked(InneractiveAdSpot inneractiveAdSpot) {
    }
    @Override
    public void onAdWillOpenExternalApp(InneractiveAdSpot inneractiveAdSpot) {
    }
    @Override
    public void onAdEnteredErrorState(InneractiveAdSpot inneractiveAdSpot, InneractiveUnitController.AdDisplayError adDisplayError) {
    }
    @Override
    public void onAdWillCloseInternalBrowser(InneractiveAdSpot inneractiveAdSpot) {
    }
    @Override
    public void onAdDismissed(InneractiveAdSpot inneractiveAdSpot) {
    }
});
```

{% endcode %}

#### Video Events: <a href="#h_01hvkbkvnewvpga227gdzbmdjr" id="h_01hvkbkvnewvpga227gdzbmdjr"></a>

{% code title="Java" %}

```java
videoContentController.setEventsListener(new VideoContentListener() {
    @Override
    public void onProgress(int totalDurationInMsec, int positionInMsec) {
    }
    @Override
    public void onCompleted() {
    }
    @Override
    public void onPlayerError() {
        /**
         * Note: onPlayerError callback method is deprecated starting from Marketplace v7.3.0,
         and won't be triggered when an error occurs.
         * Note: The SDK handles such errors internally and no further action is required.
         */
    }
});
```

{% endcode %}

#### Rewarded Events: <a href="#h_01k4w6d3ksbksg89sd3w8kacbx" id="h_01k4w6d3ksbksg89sd3w8kacbx"></a>

You can also use `InneractiveFullScreenAdRewardedListener` to receive Rewarded Ad callbacks.

{% code title="Java" %}

```java
controller.setRewardedListener(new InneractiveFullScreenAdRewardedListener() {
    @Override
    public void onAdRewarded(InneractiveAdSpot inneractiveAdSpot) {
    }
});
```

{% endcode %}

### Adding Request Listener for the Spot <a href="#id-01k7bwyagvyjxhj5dn88rshj9h" id="id-01k7bwyagvyjxhj5dn88rshj9h"></a>

The example below demonstrates how you would use a `RequestListener`:

{% code title="Java" %}

```java
InneractiveAdSpot.RequestListener mSpotListener = new InneractiveAdSpot.RequestListener() 
{
    @Override
//when the ad request sends successfully.
    public void onInneractiveSuccessfulAdRequest(InneractiveAdSpot inneractiveAdSpot) {
    }

    @Override
    public void onInneractiveFailedAdRequest(InneractiveAdSpot inneractiveAdSpot, InneractiveErrorCode inneractiveErrorCode) {
    }
};

mSpot.setRequestListener(mSpotListener);
```

{% endcode %}

## Fetching the Ad <a href="#id-01k7bwsy96q9gxdjhraahnyhs1" id="id-01k7bwsy96q9gxdjhraahnyhs1"></a>

The way in which the ad is fetched depends on the mediation type — Waterfall or SDK Bidding.

### Fetching the Ad for Waterfall <a href="#id-01k7bwsy96yt6t89qr6kgkvkhb" id="id-01k7bwsy96yt6t89qr6kgkvkhb"></a>

Use `InneractiveAdRequest adRequest` to set up the ad placement request:

{% code title="Java" %}

```java
InneractiveAdRequest adRequest = new InneractiveAdRequest("your_rewarded_spot_id");

// When ready to perform the ad request
mSpot.requestAd(adRequest);
```

{% endcode %}

Optionally, you can mute ads including `setMuteVideo(true)`:

{% code title="Java" %}

```java
InneractiveAdManager.setMuteVideo(true);
```

{% endcode %}

### Fetching the Ad for SDK Bidding <a href="#id-01k7bwvmvdmskc1pg3235dkw19" id="id-01k7bwvmvdmskc1pg3235dkw19"></a>

In SDK Bidding, DT Exchange must first generate a token for the Mediation SDK to use when identifying the request to the server.

Use `getBidderToken` to generate a Bidder Token in a background thread:

{% code title="Java" %}

```java
BidTokenProvider.getBidderToken();
```

{% endcode %}

Return type: `java.lang.String`. If an error occurs, the returned value is null.

If DT Exchange wins the auction, load the ad with the `signaldata (adm)` that was received from the server:

{% code title="Java" %}

```java
public void loadAd(String admPayload);
```

{% endcode %}

If the load is successful: `public void onInneractiveSuccessfulAdRequest(InneractiveAdSpot inneractiveAdSpot)` callback is invoked.

If the ad fails to load: `public void onInneractiveFailedAdRequest(InneractiveAdSpot inneractiveAdSpot, InneractiveErrorCode inneractiveErrorCode)` callback is invoked.

## Displaying the Ad <a href="#h_01hvkbkvne4v8pk5h0t1bx7ep5" id="h_01hvkbkvne4v8pk5h0t1bx7ep5"></a>

After a successful ad request, use `mSpot.isReady` to confirm the ad is ready and `controller.show(this);` to display the Ad:

{% code title="Java" %}

```java
// Check if we have ad content
if (mSpot.isReady()) {
// Get the spot's controller
    InneractiveFullscreenUnitController controller = (InneractiveFullscreenUnitController)mSpot.getSelectedUnitController();
// Show the ad using the Activity's context
    controller.show(this);
}
```

{% endcode %}

## Releasing an Ad Placement <a href="#releasing-an-a-d-placement-0-17" id="releasing-an-a-d-placement-0-17"></a>

DT recommends releasing the allocated resources for ad display. For more information, see [Releasing Ad Instance Resources](/dt-exchange/sdk-configuration/integrating-the-android-sdk/releasing-ad-instance-resources.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.digitalturbine.com/dt-exchange/sdk-configuration/integrating-the-android-sdk/android-ad-formats/rewarded-ads.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
