Interstital Ad
Interstitial ads are full-screen ads that cover the interface of their host app. They’re 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. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.
Load Ad
To load an interstitial ad, call the loadAd method on an IKInterstitialAd
instance and provide the ad unit ID along with an IKLoadAdListener
to receive the loaded ad or any potential errors. Note that, like other ad format load callbacks, IKLoadAdListener
utilizes IKAdError
to provide more detailed error information.
You can also check if any interstital ad already exists, then call loadAd
com.ikame.android.sdk.IKSdkController#isInterAdReadyAsync(kotlin.coroutines.Continuation<? super java.lang.Boolean>)
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#loadAd
Function Definition
fun loadAd(
screenAd: String,
callback: IKLoadAdListener?
)
Parameters
screenAd
: considered as a unitId, our team will send you the screenAd list.callback
: IKLoadAdListener Interface - Provides methods for general ad loading processes, encompassing notifications for both successful loads and failures.
Sample Usage
Show Ad
1. Basic Show Function
To display an interstitial ad, call the showAd method on an IKInterstitialAd
instance, providing the activity context, the ad unit ID, and an IKShowAdListener to handle the ad display events. The IKShowAdListener
interface provides callbacks for handling ad show failures and ad dismissals.
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#showAd(Activity, String, IKShowAdListener)
Function Definition
fun showAd(
activity: Activity?,
screen: String,
adListener: IKShowAdListener?
)
Parameters:
activity
: The Activity in which the interstitial ad will be shown. This can be null if no specific activity context is required.screen
: considered as a unitId, our team will send you the screenAd list.adListener
: IKShowAdListener - Manages ad display events.
Sample Usage
2. Show Ad with Loading Callback
To display an interstitial ad with loading callback, call the showAd method on an IKInterstitialAd
instance, providing the activity context, the ad unit ID, and an IKShowAdListener to handle the ad display events. The IKShowAdListener
interface provides callbacks for handling ad show failures and ad dismissals.The IKLoadingsAdListener
interface provides callbacks for managing the ad’s loading state.
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#showAd(Activity, String, IKShowAdListener, IKLoadingsAdListener)
Function Definition
fun showAd(
activity: Activity?,
screen: String,
adListener: IKShowAdListener?,
loadingCallback: IKLoadingsAdListener? = null
)
Parameters:
activity
: The Activity in which the interstitial ad will be shown. Can be null if no specific activity context is required.screen
: considered as a unitId, our team will send you the screenAd list.adListener
: IKShowAdListener - Manages ad display events.loadingCallback
: IKLoadingsAdListener - Managing the ad display lifecycle events while taking into account the loading time
Sample Usage
3. Show Ad Upon App Exit
This function stops loading ads after the app is exited, making it crucial for showing an interstitial ad as the user exits the app.
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#showAdBackApp(Activity, IKShowAdListener)
Function Definition
fun showAdBackApp(
activity: Activity?,
adListener: IKShowAdListener?
)
Extension with Loading Callback
Also supports a loading callback for additional handling.
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#showAdBackApp(Activity, IKShowAdListener, IKLoadingsAdListener)
Function Definition
fun showAdBackApp(
activity: Activity?,
adListener: IKShowAdListener?,
loadingCallback: IKLoadingsAdListener? = null
)
Destroy Ad
In certain scenarios, Ad
can be prone to memory leaks. Therefore, it is essential to destroy the ad when your Fragment or Activity is destroyed to manage resources properly.
Reference
com.ikame.android.sdk.format.intertial.IKInterstitialAd#destroy
Function Definition
fun destroy()
Sample usage
Ad Listener Interfaces
- IKShowAdListener: Manages ad display events.
- IKLoadAdListener Interface: Provides methods for general ad loading processes, encompassing notifications for both successful loads and failures.
- IKLoadingsAdListener: Managing the ad display lifecycle events while taking into account the loading time