Skip to content

Rewarded Ads

Str4tos edited this page May 26, 2025 · 16 revisions

Rewarded ad units enable users to play games, take surveys, or watch videos to earn in-app rewards, such as coins, extra lives, or points.

This guide explains how to integrate rewarded video ads into an Android app.

flowchart TD

A[isAutoloadEnabled] -->|auto| L((load))
L -->|success| R([onAdLoaded])
L -->|fail| F([onAdFailedToLoad])
F -->|delay| A
R --> RL[isLoaded]
S((show)) --> RL
RL -->|success| SR([onAdShowed])
RL -->|fail| SF([onAdFailedToShow])
SR --> I([onAdImpression])
SR --> C([onAdClicked])
I --> UR([onUserEarnedReward])
UR --> D([onAdDismissed])
D --> A
SF --> A
Loading

Create Ad instance

Ad instance can be initialized along with the activity before onCreate.

import com.cleveradssolutions.sdk.screen.CASRewarded;

class MyActivity extends Activity {

    final CASRewarded rewardedAd = new CASRewarded(MyApplication.CAS_ID);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ...
    }

The SDK provides the capability to create and precache multiple ad instances, enabling uninterrupted sequential ad display. CAS SDK will load mediation ads in order for each created instance.

Create Ad Content callback

The com.cleveradssolutions.sdk.screen.ScreenAdContentCallback handles events related to displaying your CASRewarded. Callbacks are called on the main thread. Before showing ad, make sure to setContentCallback().

final ScreenAdContentCallback adContentCallback = new ScreenAdContentCallback() {  
    @Override  
    public void onAdLoaded(@NonNull AdContentInfo ad) {  
        // (Optional) Called when the ad content has been successfully loaded.  
    }  
  
    @Override  
    public void onAdFailedToLoad(@NonNull AdFormat format, @NonNull AdError error) {  
        // (Optional) Called when the ad content fails to load.  
    }  
  
    @Override  
    public void onAdFailedToShow(@NonNull AdFormat format, @NonNull AdError error) {  
        // (Optional) Called when the ad content fails to show.  
    }  
  
    @Override  
    public void onAdShowed(@NonNull AdContentInfo ad) {  
        // (Optional) Called when the ad content is successfully shown.  
    }  
  
    @Override  
    public void onAdClicked(@NonNull AdContentInfo ad) {  
        // (Optional) Called when the ad content is clicked by the user.  
    }  
  
    @Override  
    public void onAdDismissed(@NonNull AdContentInfo ad) {  
        // (Optional) Called when the ad content is dismissed.  
    }  
};

Note

  • Read more about AdContentInfo structure in Impression Level Data.
  • Attempting to load a new ad from the onAdFailedToLoad() method is strongly discouraged. Limit ad load retries to avoid continuous failed ad requests in situations such as limited network connectivity.
  • When an error occurs during ad impression, executed the onAdFailedToShow only. In this case the onAdDismissed will not be executed, since the impression is not considered successful.

Load Ad

The next step is to fill out the load() method and handle the ad load callbacks.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rewardedAd.setContentCallback(adContentCallback);
    rewardedAd.load(this);
}

You can use ad load calls to build up a cache of preloaded ads before you intend to show them, so that ads can be shown with zero latency when needed. Since ads expire after an hour, you should clear this cache and reload with new ads every hour.

Autoload mode

If enabled, the ad will automatically load new content when the current ad is dismissed or completed. Additionally, it will automatically retry loading the ad if an error occurs during the loading process.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rewardedAd.setContentCallback(adContentCallback);
    rewardedAd.setAutoloadEnabled(true);
}

By default autoload disabled.

Show Ad

When you show a rewarded ad, you will use an OnRewardEarnedListener object to handle reward for the user.

rewardedAd.show(MyActivity.this, new OnRewardEarnedListener() {  
    @Override  
    public void onUserEarnedReward(@NonNull AdContentInfo ad) {  
        // Called when a user earns a reward from the ad.
        // TODO: Reward the user
    }  
});

Checking Ad Availability

Use isLoaded() to check whether an ad is currently loaded.

if (rewardedAd.isLoaded()) {
}

Even if isLoaded() returns true, it does not guarantee that the ad will be shown successfully — various issues may still prevent it from being displayed. We strongly recommend handling potential display failures via onAdFailedToShow(error) callback to ensure a smoother user experience.

By relying on these callbacks, you ensure that your application can react appropriately to real-time conditions, rather than making assumptions based on ad load state at a single point in time.

Extra fill Interstitial Ad

Controls whether interstitial ads are shown as a fallback when a rewarded video ad has no available fill. Interstitial ads do not require the user to watch the entire ad to completion. However, the OnRewardEarnedListener will still be triggered as if the user completed the rewarded video. This option is enabled by default. You can disable extra fill by following line:

rewardedAd.setExtraFillInterstitialAdEnabled(false);

Mute Ad sounds

Indicates if the application’s audio is muted. Affects initial mute state for all ads.
Use this method only if your application has its own volume controls.

CAS.getSettings().setMutedAdSounds(true);

Release ad resource

It is important to destroy() loaded but not displayed ads.

@Override  
protected void onDestroy() {  
    rewardedAd.destroy();  
    super.onDestroy();  
}

🔗 Next
Native Ad

Clone this wiki locally