Android SDK: Rewarded video

The myTarget SDK provides the ability to display rewarded video (RV) in your app.

Short (up to 30 sec), non-skippable videos, which a user opts-in to watch in exchange for rewards like virtual goods or in-game gifts. these are perfect for integrating in shop fronts and help increase the retention of the non paying users. Rewarded video ads provide high quality, engaged users to advertisers and highest eCPMs to publishers.

The myTarget SDK provides two ways to display interstitial ads: in a separate Activity or in a dialog box. We recommend that you display ads in a separate Activity, because displaying in a dialog box does not support all the features available for video ads.

Initialization

To display RV ad in your app, create an instance of the InterstitialAd class. You must specify your slotId when creating an instance.
private InterstitialAd ad;
 
private void initAd()
{
    // Enabling debug mode
    // InterstitialAd.setDebugMode(true);
    // Create an instance of InterstitialAd
    ad = new InterstitialAd(YOUR_SLOT_ID, this);
}

Loading ads

To receive notifications (such as ad load succeeded, ad load failed, or ad clicked), you must create an object that implements the InterstitialAd.InterstitialAdListener interface and set it as an event listener. Then you can start loading ad.
private InterstitialAd ad;
 
private void initAd()
{
    // Create an instance of InterstitialAd
    ad = new InterstitialAd(YOUR_SLOT_ID, this);
    // Set the event listener
    interstitialAd.setListener(new InterstitialAd.InterstitialAdListener()
    {
        @Override
        public void onLoad(InterstitialAd ad)
        {
        }
 
        @Override
        public void onNoAd(String reason, InterstitialAd ad)
        {
        }
 
        @Override
        public void onClick(InterstitialAd ad)
        {
        }
        @Override
        public void onDisplay(InterstitialAd ad)
        {
        }
 
        @Override
        public void onDismiss(InterstitialAd ad)
        {
        }
        @Override
        public void onVideoCompleted(InterstitialAd ad)
        {
           // This is used by the publisher to disburse the reward to the user
        }
    });
     
    // Start loading ad
    ad.load();
}

Displaying ads

After the ad has loaded successfully, you can start displaying RV ad.

@Override
public void onLoad(InterstitialAd ad)
{
    // Start displaying
    // in a separate Activity
    ad.show();
     
    // or in a dialog box
    //ad.showDialog();
}
Example of an RV
Example of an RV

User Data

For better ad targeting, you can optionally specify the user's gender and age. If your app uses its own localization model, you can also specify the chosen locale in ISO 639-1 format (e.g. "ru", "en", "fr", etc.).

To specify user data, use the customParams property on the created API instance.
private InterstitialAd ad;
 
private void initAd()
{
    // Create an instance of InterstitialAd
    ad = new InterstitialAd(YOUR_SLOT_ID, this);
    // Get an instance of CustomParams
    CustomParams customParams = ad.getCustomParams();
    // Set the age
    customParams.setAge(25);
    // Set the gender
    customParams.setGender(CustomParams.Gender.MALE);
}

Samples

Integration samples available in our demo-app on Github.

Mediation with other advertising SDKs

Mediation with the Google Mediation SDK and Mopub SDK is supported for an interstitial ads. Mediation is configured using the corresponding interfaces.

Google mediation

myTarget is supported by Google Mediation.

AdMob

Requirements

  • Android SDK 4.0 (API level 14) or later
  • myTarget SDK 4.6.22 or later
  • Google Play services 9.2 or later

Quick Guide for Mediating myTarget with AdMob

  1. Configure mediation settings for your AdMob ad unit
  2. Import the myTarget SDK and adapter
  3. Test your implementation
Please check the full guide.

DFP

Requirements

  • Android SDK 4.0 (API level 14) or later
  • Google Play services 9.2.0 or later

Quick Guide for Mediating myTarget with DFP

  1. Configure mediation settings for your DFP ad unit
  2. Import the myTarget SDK and adapter
  3. Test your implementation
Please check the full guide

Deprecated setup via custom class events

Please don't use it anymore.

Class Name com.my.target.ads.mediation.MyTargetAdmobCustomEventRewarded

Parameter {"slotId":"your slot id"}

Mopub mediation

Mediation with Mopub SDK requires adding mediation classes for Rewarded Video format to your project.

Mediation is configured at http://www.mopub.com/

Specify the following values in the Network settings:
Field
Value
CUSTOM EVENT CLASS
com.mopub.mobileads.MyTargetMopubCustomEventRewardedVideo
CUSTOM EVENT CLASS DATA
{"slotId":"your slot Id"}
Was this article helpful?
Да
Нет