Skip to content

Interstitial Ads

Str4tos edited this page May 26, 2025 · 12 revisions

Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

This guide explains how to integrate interstitial 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 --> 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.CASInterstitial;

class MyActivity extends Activity {

    final CASInterstitial interstitialAd = new CASInterstitial(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 CASInterstitial. 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);

    interstitialAd.setContentCallback(adContentCallback);
    interstitialAd.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);

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

By default autoload disabled.

Show Ad

Interstitial ads should be displayed during natural pauses in the flow of an app. Between levels of a game is a good example, or after the user completes a task. To show an interstitial, use the show() method.

interstitialAd.show(MyActivity.this);

Autoshow mode

Use the isAutoshowEnabled property to automatically show a loaded ad when the user returns to the app.

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

    ...
    interstitialAd.setAutoshowEnabled(true);
}

By default autoshow disabled.

Checking Ad Availability

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

if (interstitialAd.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.

Minimum interval between impressions

You can limit the posting of an interstitial ad to a period of time in seconds after the ad is closed, during which display attempts will fail. Unlimited by default 0 seconds.
That the interval starts only after the Interstitial onAdDismissed(). During interval after ad closed, display attempts will fire event onAdFailedToShow() with AdErrorCode.NOT_PASSED_INTERVAL.

interstitialAd.setMinInterval(interval);

If you need to wait for a period of time after the start of the app or after showing a Rewarded Ad until next Interstitial Ad impression then call the following method:

interstitialAd.restartInterval();

You can define a different interval for each ad instance. However, the countdown will always start from the moment any ad instance is closed within the session.

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() {  
    interstitialAd.destroy();  
    super.onDestroy();  
}

Some best practices

Consider whether interstitial ads are the right type of ad for your app.

Interstitial ads work best in apps with natural transition points. The conclusion of a task within an app, like sharing an image or completing a game level, creates such a point. Because the user is expecting a break in the action, it's easy to present an interstitial ad without disrupting their experience. Make sure you consider at which points in your app's workflow you'll display interstitial ads and how the user is likely to respond.

Remember to pause the action when displaying an interstitial ad.

There are a number of different types of interstitial ads: text, image, video, and more. It's important to make sure that when your app displays an interstitial ad, it also suspends its use of some resources to allow the ad to take advantage of them. For example, when you make the call to display an interstitial ad, be sure to pause any audio output being produced by your app.

Allow for adequate loading time.

Just as it's important to make sure you display interstitial ads at an appropriate time, it's also important to make sure the user doesn't have to wait for them to load. Loading the ad in advance by calling load() before you intend to call show() can ensure that your app has a fully loaded interstitial ad at the ready when the time comes to display one.

Don't flood the user with ads.

While increasing the frequency of interstitial ads in your app might seem like a great way to increase revenue, it can also degrade the user experience and lower clickthrough rates. Make sure that users aren't so frequently interrupted that they're no longer able to enjoy the use of your app.


🔗 Next

Clone this wiki locally