After your adunitId
is generated, you can find it on the Meson UI. Add adunitId
into the MesonInterstitial
object and pass the ActivityContext
.
val rewardedAd = MesonInterstitial(this, "AD_UNIT_ID")
MesonInterstitial rewardedAd = new MesonInterstitial(this, "AD_UNIT_ID");
Track the ad lifecycle for interstitial ads. All the available events for interstitial ads are listed below. To retrieve the rewards, use onRewardsUnlocked
callback.
rewardedAd.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>) {
}
override fun onRewardsUnlocked(ad: MesonInterstitial, rewards: Map<Any, Any>?) {
}
})
rewardedAd.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 onRewardsUnlocked(@NonNull MesonInterstitial mesonInterstitial, @Nullable Map<Object, ?> map) {
super.onRewardsUnlocked(mesonInterstitial, map);
}
@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 a rewarded 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
rewardedAd.load()
//use load() to make your interstitial ad request
rewardedAd.load();
The ad is available when load is called. It is shown to the user when 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 show method.
//Use show() to show the ad, the ad will have to be ready before calling show
rewardedAd.show()
//Use show() to show the ad, the ad will have to be ready before calling show
rewardedAd.show();
Use this method when the rewarded ad is no longer needed. We recommend using this onDestroy of the Activity.
rewardedAd.destroy()
rewardedAd.destroy();