Back to top

Interstitial Ad Units

Last Updated on: 12 Jul, 2022

Create Interstitial Ad Unit

INFO

If you miss to Initialize the SDK, this method will fail to return a response.

To create a new interstitial ad, create a MesonInterstitial object.

Kotlin

val interstitialAd = MesonInterstitial(this, "AD_UNIT_ID")

Java

MesonInterstitial interstitialAd = new MesonInterstitial(this, "AD_UNIT_ID");

Register for Postbacks

Track the ad lifecycle for interstitial ads. All the available events for interstitial ads are listed below.

Kotlin

interstitialAd.setAdListener(object:MesonInterstitialAdListener(){

    override fun onAdImpression(interstitialAd: MesonInterstitial, mesonAdData: MesonAdData?) {
    }

    override fun onAdDisplayed(interstitialAd: MesonInterstitial) {
    }

    override fun onAdDisplayFailed(interstitialAd: MesonInterstitial) {
    }

    override fun onAdDismissed(interstitialAd: MesonInterstitial) {
    }

    override fun onUserLeftApplication(interstitialAd: MesonInterstitial) {
    }

    override fun onAdLoadSucceeded(interstitialAd: MesonInterstitial) {
    }

    override fun onAdLoadFailed(interstitialAd: MesonInterstitial, status: MesonAdRequestStatus) {
    }

    override fun onAdClicked(interstitialAd: MesonInterstitial, params: HashMap<String, Any>) {
    }

})

Java

interstitialAd.setAdListener(new MesonInterstitialAdListener() {
    @Override
    public void onAdDisplayed(MesonInterstitial interstitialAd) {
    }

    @Override
    public void onAdDisplayFailed(@NonNull MesonInterstitial interstitialAd) {
    }

    @Override
    public void onAdDismissed(MesonInterstitial interstitialAd) {

    }

    @Override
    public void onUserLeftApplication(MesonInterstitial interstitialAd) {
    }

    @Override
    public void onAdLoadSucceeded(MesonInterstitial interstitialAd) {
    }

    @Override
    public void onAdImpression(MesonInterstitial interstitialAd, @Nullable MesonAdData mesonAdData) {

    }

    @Override
    public void onAdLoadFailed(MesonInterstitial interstitialAd, MesonAdRequestStatus status) {
    }

    @Override
    public void onAdClicked(MesonInterstitial interstitialAd, @NonNull HashMap<String, Object> hashMap) {

    }
});

Load Ad

The publisher can request an interstitial ad by invoking this method. This will request an ad from all demand sources, select a winner, and make it available on the SDK.

Kotlin

interstitialAd.load()

Java

interstitialAd.load()

Show Ad

The ad is available when the load is called. It is shown to the user when the show method is called. It is recommended to call this method in the onAdLoadSucceeded callback method or check isAdReady method to return true and then call the show method.

Kotlin

interstitialAd.show()

Java

interstitialAd.show();