Select platform: [Android (beta)
![New](https://developers.google.com/static/admob/images/new.svg)](https://developers.google.com/admob/android/next-gen/rewarded "View this page for the Android (beta) platform docs.") [Android](https://developers.google.com/admob/android/rewarded "View this page for the Android platform docs.") [iOS](https://developers.google.com/admob/ios/rewarded "View this page for the iOS platform docs.") [Unity](https://developers.google.com/admob/unity/rewarded "View this page for the Unity platform docs.") [Flutter](https://developers.google.com/admob/flutter/rewarded "View this page for the Flutter platform docs.")

<br />

[Rewarded ads](https://support.google.com/admob/answer/7372450) allow you to reward users with in-app items for interacting with video ads, playable ads, and surveys.

<br />

## Prerequisites

- Google Mobile Ads SDK 19.7.0 or higher.
- Complete the [Get started guide](https://developers.google.com/admob/android/quick-start).

## Always test with test ads

When building and testing your apps, make sure you use test ads rather than
live, production ads. Failure to do so can lead to suspension of your account.

The easiest way to load test ads is to use our dedicated test ad unit ID for
Android rewarded ads:

`ca-app-pub-3940256099942544/5224354917`

It's been specially configured to return test ads for every request, and you're
free to use it in your own apps while coding, testing, and debugging. Just make
sure you replace it with your own ad unit ID before publishing your app.

For details on Google Mobile Ads SDK test ads, see
[Enable test ads](https://developers.google.com/admob/android/test-ads).

## Load a rewarded ad object

| **Note:** Make all calls to the Mobile Ads SDK on the main thread.

Rewarded ads are loaded by calling the static `load()` method on the
`RewardedAd` class and passing in a `RewardedAdLoadCallback`. This is usually
done in the `onCreate()` method of an `Activity`.
Notice that like other format load callbacks, `RewardedAdLoadCallback`
leverages `LoadAdError` to provide higher fidelity error details.  

### Java

    RewardedAd.load(
        this,
        "<var translate="no">AD_UNIT_ID</var>",
        new AdRequest.Builder().build(),
        new RewardedAdLoadCallback() {
          @Override
          public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
            Log.d(TAG, "Ad was loaded.");
            MainActivity.this.rewardedAd = rewardedAd;
          }

          @Override
          public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
            Log.d(TAG, loadAdError.getMessage());
            rewardedAd = null;
          }
        });  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/java/admob/RewardedVideoExample/app/src/main/java/com/google/ads/rewardedvideoexample/MainActivity.java#L219-L243

### Kotlin

    RewardedAd.load(
      this,
      "<var translate="no">AD_UNIT_ID</var>",
      AdRequest.Builder().build(),
      object : RewardedAdLoadCallback() {
        override fun onAdLoaded(ad: RewardedAd) {
          Log.d(TAG, "Ad was loaded.")
          rewardedAd = ad
        }

        override fun onAdFailedToLoad(adError: LoadAdError) {
          Log.d(TAG, adError.message)
          rewardedAd = null
        }
      },
    )  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/kotlin/admob/RewardedVideoExample/app/src/main/java/com/google/android/gms/example/rewardedvideoexample/MainActivity.kt#L173-L190

Replace <var translate="no">AD_UNIT_ID</var> with your ad unit ID.


| **Tip:** You can use ad load calls to build up a cache of preloaded ads before you intend to show them, so that ads can be shown with zero latency when needed. Since ads expire after an hour, you should clear this cache and reload with new ads every hour.

<br />

## Set the FullScreenContentCallback

The `FullScreenContentCallback` handles events related to displaying your
`RewardedAd`. Before you show your `RewardedAd`, make sure to set the callback
like so:  

### Java

    rewardedAd.setFullScreenContentCallback(
        new FullScreenContentCallback() {
          @Override
          public void onAdDismissedFullScreenContent() {
            // Called when fullscreen content is dismissed.
            Log.d(TAG, "Ad was dismissed.");
            // Don't forget to set the ad reference to null so you
            // don't show the ad a second time.
            rewardedAd = null;
          }

          @Override
          public void onAdFailedToShowFullScreenContent(AdError adError) {
            // Called when fullscreen content failed to show.
            Log.d(TAG, "Ad failed to show.");
            // Don't forget to set the ad reference to null so you
            // don't show the ad a second time.
            rewardedAd = null;
          }

          @Override
          public void onAdShowedFullScreenContent() {
            // Called when fullscreen content is shown.
            Log.d(TAG, "Ad showed fullscreen content.");
          }

          @Override
          public void onAdImpression() {
            // Called when an impression is recorded for an ad.
            Log.d(TAG, "Ad recorded an impression.");
          }

          @Override
          public void onAdClicked() {
            // Called when an ad is clicked.
            Log.d(TAG, "Ad was clicked.");
          }
        });  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/java/admob/RewardedVideoExample/app/src/main/java/com/google/ads/rewardedvideoexample/MainActivity.java#L299-L353

### Kotlin

    rewardedAd?.fullScreenContentCallback =
      object : FullScreenContentCallback() {
        override fun onAdDismissedFullScreenContent() {
          // Called when fullscreen content is dismissed.
          Log.d(TAG, "Ad was dismissed.")
          // Don't forget to set the ad reference to null so you
          // don't show the ad a second time.
          rewardedAd = null
        }

        override fun onAdFailedToShowFullScreenContent(adError: AdError) {
          // Called when fullscreen content failed to show.
          Log.d(TAG, "Ad failed to show.")
          // Don't forget to set the ad reference to null so you
          // don't show the ad a second time.
          rewardedAd = null
        }

        override fun onAdShowedFullScreenContent() {
          // Called when fullscreen content is shown.
          Log.d(TAG, "Ad showed fullscreen content.")
        }

        override fun onAdImpression() {
          // Called when an impression is recorded for an ad.
          Log.d(TAG, "Ad recorded an impression.")
        }

        override fun onAdClicked() {
          // Called when an ad is clicked.
          Log.d(TAG, "Ad was clicked.")
        }
      }  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/kotlin/admob/RewardedVideoExample/app/src/main/java/com/google/android/gms/example/rewardedvideoexample/MainActivity.kt#L237-L274

## Show the ad

When you show a rewarded ad, you will use an `OnUserEarnedRewardListener` object
to handle reward events.  

### Java

    rewardedAd.show(
        MainActivity.this,
        new OnUserEarnedRewardListener() {
          @Override
          public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
            Log.d(TAG, "User earned the reward.");
            // Handle the reward.
          }
        });  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/java/admob/RewardedVideoExample/app/src/main/java/com/google/ads/rewardedvideoexample/MainActivity.java#L357-L368

### Kotlin

    rewardedAd?.show(
      this,
      OnUserEarnedRewardListener { rewardItem ->
        Log.d(TAG, "User earned the reward.")
        // Handle the reward.
        val rewardAmount = rewardItem.amount
        val rewardType = rewardItem.type
      },
    )  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/kotlin/admob/RewardedVideoExample/app/src/main/java/com/google/android/gms/example/rewardedvideoexample/MainActivity.kt#L278-L289

## \[Optional\] Validate server-side verification (SSV) callbacks

Apps that require extra data in [server-side
verification](https://developers.google.com/admob/android/ssv)
callbacks should use the custom data feature of rewarded ads. Any string value
set on a rewarded ad object is passed to the `custom_data` query parameter of
the SSV callback. If no custom data value is set, the `custom_data` query
parameter value won't be present in the SSV callback.

The following code sample demonstrates how to set custom data on a rewarded ad
object before requesting an ad.  

### Java

    RewardedAd.load(
        context,
        AD_UNIT_ID,
        new AdRequest.Builder().build(),
        new RewardedAdLoadCallback() {
          @Override
          public void onAdLoaded(RewardedAd ad) {
            rewardedAd = ad;
    ServerSideVerificationOptions options =
    new ServerSideVerificationOptions.Builder()
    .setCustomData("<var translate="no">SAMPLE_CUSTOM_DATA_STRING</var>")
    .build();
    rewardedAd.setServerSideVerificationOptions(options);
          }
        });  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/RewardedAdSnippets.java#L32-L46

### Kotlin

    RewardedAd.load(
      context,
      AD_UNIT_ID,
      AdRequest.Builder().build(),
      object : RewardedAdLoadCallback() {
        override fun onAdLoaded(ad: RewardedAd) {
          rewardedAd = ad
    val options =
    ServerSideVerificationOptions.Builder().setCustomData("<var translate="no">SAMPLE_CUSTOM_DATA_STRING</var>").build()
    rewardedAd?.setServerSideVerificationOptions(options)
    }
    },
    )  
    https://github.com/googleads/googleads-mobile-android-examples/blob/6252f89e35ae5b73053ed3f74bf551114920b7ad/kotlin/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/RewardedAdSnippets.kt#L30-L42

Replace <var translate="no">SAMPLE_CUSTOM_DATA_STRING</var> with your custom data.

If you want to set the custom reward string, you must do so before showing the
ad.
| **Key Point:** The custom reward string is [percent
| escaped](https://en.wikipedia.org/wiki/Percent-encoding) and might require decoding when parsed from the SSV callback.

## FAQ

Is there a timeout for the initialization call?
:   After 10 seconds, Google Mobile Ads SDK invokes the
    `OnInitializationCompleteListener` even if a mediation network still hasn't
    completed initialization.

What if some mediation networks aren't ready when I get the initialization callback?

:   We recommend loading an ad inside the callback of the
    `OnInitializationCompleteListener`. Even if a mediation network is not ready,
    Google Mobile Ads SDK still asks that network for an ad. So if a
    mediation network finishes initializing after the timeout, it can still
    service future ad requests in that session.

    You can continue to poll the initialization status of all adapters throughout
    your app session by calling `MobileAds.getInitializationStatus()`.

How do I find out why a particular mediation network isn't ready?

:   `AdapterStatus.getDescription()` describes why an adapter is not ready to
    service ad requests.

Does the [`onUserEarnedReward()`](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/OnUserEarnedRewardListener#onUserEarnedReward(com.google.android.gms.ads.rewarded.RewardItem)) callback always get called before the [`onAdDismissedFullScreenContent()`](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/FullScreenContentCallback#onAdDismissedFullScreenContent()) callback?

:   For Google ads, all `onUserEarnedReward()` calls occur before
    `onAdDismissedFullScreenContent()`. For ads served through
    [mediation](https://developers.google.com/admob/android/mediation), the third-party ad
    network SDK's implementation determines the callback order. For ad network
    SDKs that provide a single close callback with reward information, the
    mediation adapter invokes `onUserEarnedReward()` before
    `onAdDismissedFullScreenContent()`.

## Examples on GitHub

- Rewarded ads example: [Java](https://github.com/googleads/googleads-mobile-android-examples/tree/main/java/admob/RewardedVideoExample) \| [Kotlin](https://github.com/googleads/googleads-mobile-android-examples/tree/main/kotlin/admob/RewardedVideoExample)

## Next steps

Explore the following topics:

- [User privacy](https://developers.google.com/admob/android/privacy)
- [Optimized SDK initialization and ad loading
  (beta)](https://developers.google.com/admob/android/optimize-initialization)