Rewarded Video Ad format

A rewarded ad is a full-screen video ad that users have the option to watch in full to receive an in-app reward. Rewards typically come in the form of in-game currency such as lives or coins. The RTB-Stack SDK supports both HTML and VAST video formats for rewarded ads.

Setting Up Rewarded Ads

Setting up a rewarded ad involves five main steps:

  1. Instantiate and configure the RewardedAdView.
  2. Load a Rewarded ad.
  3. Display the ad when it is ready.
  4. Receive a rewarding event from a RewardedAdListener callback.
  5. Call activityOnDestroy() when the screen is destroyed.

Example: Load and Display Rewarded Ad

Here is a basic example of how to load and display a rewarded ad in the onCreate() method of an Activity:

private RewardedAdView adView;

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   SDKSettings.setRequestBaseUrl("Your endpoint request url");

   adView = new RewardedAdView(this);
   adView.setTagID("Your custom tag id");

   adView.setAdListener(new AdListener() {
       @Override
       public void onAdLoaded(AdView adView) {
           RewardedAdView rewardedAdView = (RewardedAdView) adView;
           if(rewardedAdView.isReady()) {
               rewardedAdView.show();
           }
       }

       @Override
       public void onAdLoaded(NativeAdResponse nativeAdResponse) {
       }

       @Override
       public void onAdRequestFailed(AdView adView, ResultCode resultCode) {
       }

       @Override
       public void onAdExpanded(AdView adView) {
       }

       @Override
       public void onAdCollapsed(AdView adView) {
       }

       @Override
       public void onAdClicked(AdView adView) {
       }

       @Override
       public void onAdClicked(AdView adView, String s) {
       }
   });

   adView.loadAd();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if(adView != null) {
        adView.activityOnDestroy();
    }
}

Note:

  • Endpoint Request URL: You can obtain an Endpoint Request URL from the Edit Endpoint window as described here
  • Custom Tag ID: Assign a random string as a Tag ID to facilitate tracking and reporting. For example, you might use "Rewarded_Video_30s_CoinReward" to specify a rewarded video ad that grants a coin reward after viewing.

Listen for Reward Events

To receive reward events, set a RewardedAdListener:

adView.setRewardedAdListener(new RewardedAdListener() {
    @Override
    public void onRewardedAdOpened() {
    }

    @Override
    public void onRewardedAdClosed() {
    }

    @Override
    public void onUserEarnedReward(RewardItem rewardItem) {
        Toast.makeText(MainActivity.this, "You earned a reward!", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRewardedAdFailedToShow(RewardedErrorCode rewardedErrorCode) {
    }
});

Rewarded Options

The RewardedAdView allows for configuring various options related to how an ad’s URL is handled:

  • Open the URL in an in-app browser (WebView):
  • adView.setClickThroughAction(ANClickThroughAction.OPEN_SDK_BROWSER);
  • Open the URL in the device browser:
  • adView.setClickThroughAction(ANClickThroughAction.OPEN_DEVICE_BROWSER);
  • Return the URL in the AdListener.onAdClicked() callback:
  • adView.setClickThroughAction(ANClickThroughAction.RETURN_URL);
Updated on March 14, 2025