Interstitial Ad format

Interstitial ads are full-screen ads that cover the interface of their host app. They are 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. The RTB-Stack SDK supports both HTML and VAST video content for these ads.

Setting Up Interstitial Ads

Setting up an interstitial ad involves four main steps:

  1. Instantiate and configure the InterstitialAdView.
  2. Load the Interstitial ad.
  3. Display the ad when it is ready.
  4. Call activityOnDestroy() when the screen is destroyed.

Example: Load and Display Interstitial Ad

Below is a basic example of how to load and display an interstitial ad. In this example, we instantiate the InterstitialAdView and load an ad in the onCreate() method of an Activity. The ad is displayed when it is loaded and ready:

private InterstitialAdView adView;

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

   adView = new InterstitialAdView(this);
   adView.setTagID("Your custom tag id");
   adView.setAdListener(new AdListener() {
       @Override
       public void onAdLoaded(AdView adView) {
           InterstitialAdView interstitialAdView = (InterstitialAdView) adView;
           if(interstitialAdView.isReady()) {
               interstitialAdView.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 for tracking and reporting purposes. For example, use "Interstitial_Homepage_Promo" to indicate an interstitial ad promoting a special offer on the homepage.

Interstitial Options

The InterstitialAdView 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