Stay organized with collections Save and categorize content based on your preferences.
Rewarded adsallow you to reward users with in-app items for interacting with video ads, playable ads, and surveys.
PrerequisitesWhen 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 more information about how the Mobile Ads SDK's test ads work, see 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.
Replace AD_UNIT_ID 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. Set the FullScreenContentCallbackThe FullScreenContentCallback
handles events related to displaying your RewardedAd
. Before you show your RewardedAd
, make sure to set the callback like so:
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.");
}
});
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.")
}
}
Show the ad
When you show a rewarded ad, you will use an OnUserEarnedRewardListener
object to handle reward events.
rewardedAd.show(
MainActivity.this,
new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
Log.d(TAG, "User earned the reward.");
// Handle the reward.
}
});
Kotlin
rewardedAd?.show(
this,
OnUserEarnedRewardListener { rewardItem ->
Log.d(TAG, "User earned the reward.")
// Handle the reward.
val rewardAmount = rewardItem.amount
val rewardType = rewardItem.type
},
)
[Optional] Validate server-side verification (SSV) callbacks
Apps that require extra data in server-side verification 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.
Replace SAMPLE_CUSTOM_DATA_STRING 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 and might require decoding when parsed from the SSV callback. FAQOnInitializationCompleteListener
even if a mediation network still hasn't completed initialization.
We recommend loading an ad inside the callback of the OnInitializationCompleteListener
. Even if a mediation network is not ready, the 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()
.
AdapterStatus.getDescription()
describes why an adapter is not ready to service ad requests.
onUserEarnedReward()
callback always get called before the onAdDismissedFullScreenContent()
callback?
For Google ads, all onUserEarnedReward()
calls occur before onAdDismissedFullScreenContent()
. For ads served through 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()
.
Explore the following topics:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[[["Rewarded ads incentivize users with in-app rewards for engaging with video ads, playable ads, and surveys."],["To implement rewarded ads, you need Google Mobile Ads SDK 19.7.0 or higher and complete the Get started guide."],["Before publishing your app, replace the test ad unit ID (`ca-app-pub-3940256099942544/5224354917`) with your own ad unit ID."],["Implement `FullScreenContentCallback` to manage rewarded ad display events and `OnUserEarnedRewardListener` to handle reward events."],["Server-side verification (SSV) can be used for enhanced security, and custom data can be passed to SSV callbacks."]]],["Rewarded ads reward users for interacting with ads. To implement, ensure you have the correct SDK version and use test ads with the provided ID: `ca-app-pub-3940256099942544/5224354917`. Load ads using `RewardedAd.load()`, and set a `FullScreenContentCallback` to manage ad display events. To show an ad use an `OnUserEarnedRewardListener` to handle rewards. For server-side verification, use the `custom_data` feature. Ad loading can be used to create a cache of preloaded ads.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4