Android SDK: Rewarded video

The myTarget SDK provides the ability to display an rewarded ads in your app.

Initialization

To display rewarded ad in your app, create an instance of the RewardedAd class. You must specify your slotId when creating an instance.

private RewardedAd ad;
 
private void initAd()
{
    // Turn on debug mode
    // RewardedAd.setDebugMode(true);
     
    // Create instance of RewardedAd
    ad = new RewardedAd(YOUR_SLOT_ID, this);
}

Loading ads

To receive notifications (such as ad load succeeded, ad load failed, reward earned, ad clicked etc.), you must set a listener, which implements the RewardedAd.RewardedAdListener interface, on the RewardedAd instance. Then you can start loading ad.
private RewardedAd ad;
 
private void initAd()
{
    // Creating RewardedAd instance
    ad = new RewardedAd(YOUR_SLOT_ID, this);
    // Set listener
    ad.setListener(new RewardedAd.RewardedAdListener()
    {
        @Override
        public void onLoad(RewardedAd ad)
        {
        }
 
        @Override
        public void onNoAd(String reason, RewardedAd ad)
        {
        }
  
        @Override
        public void onClick(RewardedAd ad)
        {
        }
  
        @Override
        public void onDisplay(RewardedAd ad)
        {
        }
  
        @Override
        public void onDismiss(RewardedAd ad)
        {
        }
  
        @Override
        void onReward(@NonNull Reward reward, @NonNull RewardedAd ad)
        {
        }
    });
     
    // Start loading
    ad.load();
}

Displaying ads

After the ad has loaded successfully, you can start displaying rewarded ad.
@Override
public void onLoad(RewardedAd ad)
{
    // Запускаем показ
    ad.show();
}

Reward

When reward is received, callback onReward will be called on interface with Reward object containing field type
Reward.type;
Was this article helpful?
Yes
No