Interstitial Ad
Below are the steps to load and show an Interstitial ad using xGrowth SDK on your app
1
2
Call loadAd()
AdSterAdLoader.Companion.builder().withAdsListener(new MediationAdListener(){
@Override
public void onInterstitialAdLoaded(@NonNull MediationInterstitialAd ad) {
super.onInterstitialAdLoaded(ad);
//Show interstitial ad here
}
@Override
public void onFailure(@NonNull AdError adError) {
//Handle failure callback here
}
}).withInterstitialAdEventsListener(new InterstitialAdEventsListener() {
@Override
public void onAdClicked() {
//Handle ad click here
}
@Override
public void onAdImpression() {
//Handle ad impression here
}
@Override
public void onAdOpened() {
//Handle ad open here
}
@Override
public void onAdClosed() {
//Handle ad closed here
}
@Override
public void onAdRevenuePaid(double revenue, @NotNull String adUnitId,@NotNull String network) {
// Callback which provides revenue and the network which provided it
}
}).build().loadAd(configuration.build());3
Show the interstitial ad inside onInterstitialAdLoaded
@Override
public void onInterstitialAdLoaded(@NonNull MediationInterstitialAd ad) {
super.onInterstitialAdLoaded(ad);
ad.showAd(getApplicationContext());
}override fun onInterstitialAdLoaded (ad: MediationInterstitialAd) {
super.onInterstitialAdLoaded (ad)
ad.showAd(activity);
}Last updated