Interstitial Ads
Interstitial ads are full-screen or full-page ads that temporarily cover an app’s interface. They’re typically shown at natural pauses or transition points—such as after completing a level in a game or when navigating between major views.
This guide shows you how to integrate interstitial ads into an your app.
Load ad
Create an instance of CTInterstitial, passing in the placementId and calling the loadAd method.
- Java
java
CTAdRequest adRequest = new CTAdRequest.Builder()
.setPlacementId("INTERSTITIAL_PLACEMENT_ID")// [necessary] placementId from carty publisher
.setMute(true)// [optional] does video ads mute play, sdk default value true
.build();
CTInterstitial ctInterstitial = new CTInterstitial(adRequest);
ctInterstitial.loadAd();- kotlin
kotlin
val adRequest = CTAdRequest.Builder()
.setPlacementId("INTERSTITIAL_PLACEMENT_ID")// [necessary] placementId from carty publisher
.setMute(true)// [optional] does video ads mute play, sdk default value true
.build()
val ctInterstitial = CTInterstitial(adRequest)
ctInterstitial.loadAd()Register Listener
It is recommended to register a listener before calling the CTInterstitial.loadAd method.
java
ctInterstitial.setInterstitialAdListener(new CTInterstitialAdListener() {
@Override
public void onLoaded(CTBaseAd baseAd) {
}
@Override
public void onLoadFailed(CTAdError adError) {
}
@Override
public void onShown(CTBaseAd baseAd) {
}
@Override
public void onShowFailed(CTBaseAd baseAd, CTAdError adError) {
}
@Override
public void onClicked(CTBaseAd baseAd) {
}
@Override
public void onClosed(CTBaseAd baseAd) {
}
});- kotlin
kotlin
ctInterstitial.setInterstitialAdListener(object : CTInterstitialAdListener {
override fun onLoaded(baseAd: CTBaseAd?) {
}
override fun onLoadFailed(adError: CTAdError?) {
}
override fun onShown(baseAd: CTBaseAd?) {
}
override fun onShowFailed(baseAd: CTBaseAd?, adError: CTAdError?) {
}
override fun onClicked(baseAd: CTBaseAd?) {
}
override fun onClosed(baseAd: CTBaseAd?) {
}
})Make sure ad ready
Before you showAd, you need to check if the ad is ready.
java
ctInterstitial.isReady();- kotlin
kotlin
ctInterstitial.isReady()Display ad
Call showAd on the CTInterstitial object that you instantiated
java
ctInterstitial.showAd(activity);- kotlin
kotlin
ctInterstitial.showAd(activity)