Enabling rewarded ads

A rewarded ad is a configurable full-screen ad. The user gets a reward for viewing the ad.

To enable advertising:

Creating a rewarded ad

  1. Add an object of the RewardedAd class.

    mRewardedAd = new RewardedAd(this);
  2. Set the Block ID using the setBlockId method.

    Block ID is a unique identifier in the adf-XXXXXX/YYYYYY format, which is assigned in the Partner interface.

    In the mobile mediation interface, the Block ID is called the location ID.

  3. If you are assigning rewards on the application side (“client-side reward”), implement the onRewarded interface method. It is called when the impression is registered and the user can be rewarded for viewing the ad. Use this chance to give the reward to the app user.

After creating and configuring an object of the RewardedAd class, you need to install a listener of the RewardedAdEventListener interface for the ad object in order to track events (like opening or closing the ad, exiting the app, or loading the app successfully or unsuccessfully).

Loading ads

After creating and configuring the object of the RewardedAd class, load ads. To load an ad, use the loadAd method, which takes the AdRequest object as a parameter (or Builder, which optionally accepts ad targeting data).

Displaying ads

Rewarded ads are loaded in the background immediately after the loadAd method is called. To display rewarded ads, call the show method.

We recommend checking whether the ad has actually loaded. To do this, call the isLoaded method.


You don't need to check this if the show method is called after the onAdLoaded callback has been triggered.

Example of working with rewarded ads

The following code demonstrates how to create and configure a RewardedAd object, register the listener, and load and display the rewarded ad:

public class RewardedAdExample extends Activity {
    private static final String BLOCK_ID = "YOUR_BLOCK_ID";
    private RewardedAd mRewardedAd;
    public void onCreate(Bundle savedInstanceState) {
        // Creating a RewardedAd instance.
        mRewardedAd = new RewardedAd(this);
        // Creating an ad targeting object.
        final AdRequest adRequest = new AdRequest.Builder().build();
        // Registering a listener to track events in the ad.
        mRewardedAd.setRewardedAdEventListener(new RewardedAdEventListener.SimpleRewardedAdEventListener() {
            public void onLoaded() {
        // Loading ads.

If advertising is integrated this way, the ad block appears after the app starts.