Implement rewarded ads in Android
Implement rewarded ads in your Android app. Load ad content, display it through Java code, and use a listener to manage ad events and reward logic.
Read time 1 minuteLast updated a month ago
Rewarding users for watching ads increases user engagement, resulting in higher revenue. For example, games might reward users with in-game currency, consumables, additional lives, or experience-multipliers. For more information on how to effectively design your rewarded ads, refer to the monetization strategy guide.
Rewarded video ad load example
Call on the retained instance, passing the activity, a , and a . The listener provides , , and callbacks for standard ad lifecycle events, as well as two reward-specific callbacks: , which fires when the user earns a reward, and , which fires after it when the ad closes. Because both callbacks can fire in sequence, reward logic should be handled in only one of them, typically by checking a flag like to avoid granting the reward twice.
show()RewardedAdShowConfigurationRewardedShowListeneronStartedonClickedonFailedonRewardedonCompletedshouldAlwaysRewardUser()Ads expire a set time after they load if they aren't shown. Set on the loaded ad instance to detect this. This is especially relevant for rewarded ads since they're often preloaded and held until the user opts in. Calling on an expired ad fails, so use the callback to clear your stored reference and issue a new call so a fresh ad is ready when needed.
onAdExpiredshow()load()RewardedAd.load(loadConfig, (rewardedAd, error) -> { if (rewardedAd != null) { // Ad loaded successfully, ready to be shown this.rewardedAd = rewardedAd; rewardedAd.setOnAdExpired(expiredAd -> { this.rewardedAd = null; // reload here }); } else { // Handle load error }});
Rewarded video ad show example
rewardedAd.show(activity, showConfig, rewardedAdShowListener){ @Override public void onStarted(@NonNull InterstitialAd ad) { /* displayed */ } @Override public void onClicked(@NonNull InterstitialAd ad) { /* clicked */ } @Override public void onCompleted(@NonNull InterstitialAd ad, @NonNull ShowFinishState state) { /* hidden */ } @Override public void onFailed(@NonNull InterstitialAd ad, @NonNull UnityAdsError error) { /* failed */ } }
Next steps: Refer to Implement banner ads in Android.