Skip to main content

Interstitial

Static or video ads that can appear at natural nodes or transition points can create an engaging brand experience without interrupting users' use of the app.

Introduction

The ad format that appears when the user opens or switches to your app. You can refer to the ad source Hisavana's supported ad sizes of 1:1, 9:16, and 3:2. The effect diagram is as follows:

1:19:163:2

Load Ads

Please set the corresponding parameters and listening callbacks.

Strongly recommended: During ad display, avoid using the same ad object to repeatedly initiate ad requests. If you need to initiate a new ad request, create a new ad object. Otherwise, the ad request will be invalid and an error message will be returned through the onError callback.

// Initialize the interstitial ad object, where "interstitial_id" is the interstitial ad slot ID
TInterstitialAd mTInterstitialAd = new TInterstitialAd(this, "interstitial_id");
// Construct ad request body
TAdRequestBody tAdRequest = new TAdRequestBody.AdRequestBodyBuild()
.setAdListener(new TAdAlliance())
.build();
// Set ad request body
mTInterstitialAd.setRequestBody(tAdRequest);
// After loading the advertisement, the optimal advertisement callback will be returned within the set waiting time
mTInterstitialAd.loadAd();

// Ad listener, listens for callbacks of ad loading completion (filling), display, click, exception, and closing actions
private static class TAdAlliance extends TAdListener {

// Loading completion callback (applicable ad slots: all ad slots)
@Override
public void onLoad() {
// Ad loaded callback
}

// Abnormal callback (applicable ad slots: all ad slots)
@Override
public void onError(TAdErrorCode errorCode) {
// Ad failed callback
}

// Display callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onShow(int source) {
// Ad show callback
}

// Click callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onClicked(int source) {
// Ad click callback
}

// Close callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onClosed(int source) {
// Ad close callback
}

// Display failure callback (applicable ad slots: all ad slots)
@Override
public void onShowError(TAdErrorCode errorCode) {
// Ad show failed callback
}
}

Reminder: source represents the advertising source, please refer to Advertising Source Association Table; For example: this time the advertisement is filled with pangle ads, then source=6.

Display Ads

Please show interstitials.

// Show interstitial ads
if (mTInterstitialAd != null && mTInterstitialAd.hasAd()) {
mTInterstitialAd.show(context);
}
/**
* Optional
* For applications that need to count the arrival of advertising scenes, you can set the scene value yourself.
* The main purpose is to count the utilization rate of the current advertising scene. The first parameter is the custom scene name, and the second parameter is the number of advertisements.
*/
String sceneToken = mTInterstitialAd.enterScene("interstitial_scene_name", 1);
if (mTInterstitialAd != null && mTInterstitialAd.hasAd()) {
mTInterstitialAd.show(context, sceneToken);
}

Destroy Ads

After exiting the advertising scene, please destroy the advertising object.

@Override
protected void onDestroy() {
super.onDestroy();
if (mTInterstitialAd != null) {
mTInterstitialAd.destroy();
mTInterstitialAd = null;
}
}

Other APIs

API callIntroduce
mTInterstitialAd.hasAd()Are there any ads currently available