Interstitial Ads are loaded automatically. You can observe ad loading events by specifying the delegate:
Java Kotlin
Copy Interstitial interstitial = new Interstitial( this ) ;
interstitial . setLoadDelegate ( this );
Copy val interstitial: Interstitial ? = Interstitial ( this )
interstitial?. setLoadDelegate ( this )
The delegate should implement the following methods:
Java Kotlin
Copy @ Override
public void didLoad( AdInfo adInfo) {
print( "Interstitial - didLoadAd. AdInfo: " + adInfo)
}
@ Override
public void didFailToLoad( AdInfo adInfo , Error error) {
print( "Interstitial - didFailToLoadAd. AdInfo:" + adInfo + " Error: " + error . getLocalizedMessage())
}
Copy override fun didLoad (adInfo: AdInfo ?) {
print ( "Interstitial - didLoadAd. AdInfo: $adInfo" )
}
override fun didFailToLoad (adInfo: AdInfo ?, error: Error ) {
print ( "Interstitial - didFailToLoadAd. AdInfo: $adInfo. Error: ${ error. getLocalizedMessage () } " )
}
Showing an Interstitial Ad
To show an interstitial ad, call showWithDelegate
instance method of the Interstitial
class:
Java Kotlin
Copy interstitial . showWithDelegate (Activity , showDelegate);
Copy interstitial. showWithDelegate (Activity, showDelegate)
The delegate should implement the following methods:
Java Kotlin
Copy @ Override
public void didDisplayAd( AdInfo adInfo) {
System . out . println ( "Interstitial - didDisplayAd. AdInfo:" + adInfo)
}
@ Override
public void didClickAd( AdInfo adInfo) {
System . out . println ( "Interstitial - didDisplayAd. AdInfo:" + adInfo );
}
@ Override
public void didHideAd( AdInfo adInfo) {
System . out . println ( "Interstitial - didHideAd. AdInfo:" + adInfo );
}
@ Override
public void didFailToDisplayAd( AdInfo adInfo , Error error) {
System . out . println ( "Interstitial - didFail toDisplayAd. AdInfo:" + adInfo + error . getLocalizedMessage ());
}
@ Override
public void allNetworksDidFailToDisplayAd() {
System . out . println ( "Interstitial - allNetworksDidFailToDisplayAd." );
}
Copy override fun didDisplayAd (adInfo: AdInfo ?) {
print ( "Interstitial - didDisplayAd. AdInfo: $adInfo" )
}
override fun didClickAd (adInfo: AdInfo ?) {
print ( "Interstitial - didClickAd. AdInfo: $adInfo" )
}
override fun didHideAd (adInfo: AdInfo ?) {
print ( "Interstitial - didHideAd. AdInfo: $adInfo" )
}
override fun didFailToDisplayAd (adInfo: AdInfo ?, error: Error ) {
print ( "Interstitial - didFail toDisplayAd. AdInfo: $adInfo. Error: ${ error. getLocalizedMessage () } " )
}
override fun allNetworksDidFailToDisplayAd () {
print ( "Interstitial - allNetworksDidFailToDisplayAd." )
}
Stopping and Starting Auto-Load
By default, Interstitials preload ads before any load attempt. So an Interstitial can use already preloaded ads instead of waiting on a manual load call to load new ads. To disable this feature you need to call the following method:
Java Kotlin
Copy interstitial . setAutoload ( false );
Copy interstitial. setAutoload ( false )
Once you disable autoload, you should load ads manually every time you need them to show:
Last updated 5 months ago