Interstitial
Static or video ads displayed at natural breakpoints or transition points — delivering an engaging brand experience without disrupting the user's flow.
Overview
An ad format that appears when the user opens or switches to your app. Refer to the Hisavana SSP ad source for supported sizes: 1:1, 9:16, and 3:2. Sample previews:
| 1:1 | 9:16 | 3:2 |
|---|---|---|
![]() | ![]() | ![]() |
We recommend downloading and trying the Mediation Demo to get a more intuitive and in-depth understanding of the SDK's features and usage.
Load Ad
Set the required parameters and listener callbacks. Pay close attention to which ad unit types each callback applies to, to avoid integration errors.
Strongly recommended: Avoid making a new ad request using the same ad object while an ad is being displayed. If you need to make a new request, create a new ad object. Otherwise the request will be invalid and an error will be returned via the onError callback.
// Initialize the interstitial ad object; "interstitial_id" is the interstitial ad unit ID
TInterstitialAd mTInterstitialAd = new TInterstitialAd(this, "interstitial_id");
// Build the ad request body
TAdRequestBody tAdRequest = new TAdRequestBody.AdRequestBodyBuild()
.setAdListener(new TAdAlliance())
.build();
// Set the ad request body
mTInterstitialAd.setRequestBody(tAdRequest);
// Load the ad and return the optimal ad within the configured wait time
mTInterstitialAd.loadAd();
// Ad listener — callbacks for load, show, click, error, and close events
private static class TAdAlliance extends TAdListener {
// Load callback (applicable to: all ad units)
@Override
public void onLoad() {
// Ad loaded callback
}
// Error callback (applicable to: all ad units)
@Override
public void onError(TAdErrorCode errorCode) {
// Ad failed callback
}
// Show callback (applicable to: Splash, Interstitial, Banner, Reward)
@Override
public void onShow(int source) {
// Ad show callback
}
// Click callback (applicable to: Splash, Interstitial, Banner, Reward)
@Override
public void onClicked(int source) {
// Ad click callback
}
// Close callback (applicable to: Splash, Interstitial, Banner, Reward)
@Override
public void onClosed(int source) {
// Ad close callback
}
// Show error callback (applicable to: all ad units)
@Override
public void onShowError(TAdErrorCode errorCode) {
// Ad show failed callback
}
}
Reminder: source indicates the ad network. Refer to the Ad Source Correlation Table. For example, if the filled ad is from Pangle, then source = 6.
Show Ad
Display the interstitial ad.
// Show the interstitial ad
if (mTInterstitialAd != null && mTInterstitialAd.hasAd()) {
mTInterstitialAd.show(context);
}
/**
* Optional
* For apps that need to track ad scene impressions, set the scene value here.
* The first parameter is a custom scene name; the second is the ad count.
*/
String sceneToken = mTInterstitialAd.enterScene("interstitial_scene_name", 1);
if (mTInterstitialAd != null && mTInterstitialAd.hasAd()) {
mTInterstitialAd.show(context, sceneToken);
}
Destroy Ad
Release ad resources promptly to prevent memory leaks.
// Destroy the ad object when leaving the ad scene.
@Override
protected void onDestroy() {
super.onDestroy();
if (mTInterstitialAd != null) {
mTInterstitialAd.destroy();
mTInterstitialAd = null;
}
}
Other APIs
| API | Description |
|---|---|
| mTInterstitialAd.hasAd() | Whether a ready ad is available |


