# Class RewardedAd

java.lang.Object
com.codename1.ads.RewardedAd

public class RewardedAd extends java.lang.Object

An opt-in full screen ad that grants the user a reward for watching it to completion. Pass the `OnUserEarnedRewardListener` to `show(OnUserEarnedRewardListener)` to be notified when the reward is earned.

    RewardedAd ad = new RewardedAd("ca-app-pub-xxx/yyy");
    ad.setAdListener(new AdListener() {
        public void onLoaded() {
            ad.show(new OnUserEarnedRewardListener() {
                public void onUserEarnedReward(RewardItem r) {
                    grantCoins(r.getAmount());
                }
            });
        }
    });
    ad.load();

For valuable rewards, verify server side with `setServerSideVerificationOptions(ServerSideVerificationOptions)` rather than trusting the client callback.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RewardedAd(String adUnitId)`
  Creates a rewarded ad for the given ad unit id.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `dispose()`
  Releases the resources held by this ad.
  `AdListener`
  `getAdListener()`
  The listener notified of this ad's lifecycle events, may be null.
  `boolean`
  `isLoaded()`
  True when an ad is loaded and ready to `show()`.
  `void`
  `load()`
  Loads an ad with default targeting.
  `void`
  `load(AdRequest request)`
  Loads an ad using the supplied targeting metadata.
  `void`
  `setAdListener(AdListener listener)`
  Sets the listener notified of this ad's lifecycle events.
  `void`
  `setOnUserEarnedRewardListener(OnUserEarnedRewardListener listener)`
  Sets the reward listener used by `show()`.
  `void`
  `setServerSideVerificationOptions(ServerSideVerificationOptions options)`
  Configures server side verification (SSV) of the reward.
  `void`
  `show()`
  Presents the loaded ad.
  `void`
  `show(OnUserEarnedRewardListener listener)`
  Presents the ad and registers the reward listener in one call.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RewardedAd

    public RewardedAd(String adUnitId)

    Creates a rewarded ad for the given ad unit id.

    ###### Parameters

    - `adUnitId`: the ad unit identifier from the network console

- ## Method Details

  - ### setOnUserEarnedRewardListener

    public void setOnUserEarnedRewardListener(OnUserEarnedRewardListener listener)
    Sets the reward listener used by `show()`.

  - ### setServerSideVerificationOptions

    public void setServerSideVerificationOptions(ServerSideVerificationOptions options)
    Configures server side verification (SSV) of the reward. Must be set before `show()`.

  - ### show

    public void show(OnUserEarnedRewardListener listener)

    Presents the ad and registers the reward listener in one call.

    ###### Parameters

    - `listener`: notified when the reward is earned

  - ### setAdListener

    public void setAdListener(AdListener listener)
    Sets the listener notified of this ad's lifecycle events.

  - ### getAdListener

    public AdListener getAdListener()
    The listener notified of this ad's lifecycle events, may be null.

  - ### load

    public void load()
    Loads an ad with default targeting.

  - ### load

    public void load(AdRequest request)

    Loads an ad using the supplied targeting metadata.

    ###### Parameters

    - `request`: optional targeting metadata, may be null

  - ### isLoaded

    public boolean isLoaded()
    True when an ad is loaded and ready to `show()`.

  - ### show

    public void show()
    Presents the loaded ad. Does nothing if no ad is loaded.

  - ### dispose

    public void dispose()
    Releases the resources held by this ad.