After your adunitId
is generated, you can find it on the Meson UI. Add adunitId
into the MesonInterstitial
object and pass the ActivityContext
.
val interstitialAd = MesonInterstitial(this, "AD_UNIT_ID")
MesonInterstitial interstitialAd = new MesonInterstitial(this, "AD_UNIT_ID");
Track the ad lifecycle for interstitial ads. All the available events for interstitial ads are listed below.
interstitialAd.setAdListener(object : MesonInterstitialAdListener() {
override fun onAdImpression(ad: MesonInterstitial, mesonAdData: MesonAdData?) {
}
override fun onAdDisplayed(ad: MesonInterstitial) {
}
override fun onAdDisplayFailed(ad: MesonInterstitial) {
}
override fun onAdDismissed(ad: MesonInterstitial) {
}
override fun onUserLeftApplication(ad: MesonInterstitial) {
}
override fun onAdLoadSucceeded(ad: MesonInterstitial) {
}
override fun onAdLoadFailed(ad: MesonInterstitial, status: MesonAdRequestStatus) {
}
override fun onAdClicked(ad: MesonInterstitial, params: HashMap<String, Any>) {
}
})
interstitialAd.setAdListener(new MesonInterstitialAdListener() {
@Override
public void onUserLeftApplication(MesonInterstitial mesonInterstitial) {
super.onUserLeftApplication(mesonInterstitial);
}
@Override
public void onAdImpression(MesonInterstitial mesonInterstitial, @Nullable MesonAdData mesonAdData) {
super.onAdImpression(mesonInterstitial, mesonAdData);
}
@Override
public void onAdClicked(MesonInterstitial mesonInterstitial, @NonNull HashMap<String, Object> hashMap) {
super.onAdClicked(mesonInterstitial, hashMap);
}
@Override
public void onAdLoadFailed(MesonInterstitial mesonInterstitial, @NonNull MesonAdRequestStatus mesonAdRequestStatus) {
super.onAdLoadFailed(mesonInterstitial, mesonAdRequestStatus);
}
@Override
public void onAdLoadSucceeded(MesonInterstitial mesonInterstitial) {
super.onAdLoadSucceeded(mesonInterstitial);
}
@Override
public void onAdDisplayFailed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDisplayFailed(mesonInterstitial);
}
@Override
public void onAdDismissed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDismissed(mesonInterstitial);
}
@Override
public void onAdDisplayed(@NonNull MesonInterstitial mesonInterstitial) {
super.onAdDisplayed(mesonInterstitial);
}
});
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.
//use load() to make your interstitial ad request
interstitialAd.load()
//use load() to make your interstitial ad request
interstitialAd.load();
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.
//Use show() to show the ad, the ad will have to be ready before calling show
interstitialAd.show()
//Use show() to show the ad, the ad will have to be ready before calling show
interstitialAd.show();
Use this method when the Interstitial ad is no longer needed. We recommend using this onDestroy of the Activity.
interstitialAd.destroy()
interstitialAd.destroy();