Display interstitial ad on Android
Display an interstitial ad
val interstitialAd = AdropInterstitialAd(context, "YOUR_UNIT_ID")
interstitialAd.interstitialAdListener = object : AdropInterstitialAdListener {
override fun onAdReceived(ad: AdropInterstitialAd) {
Log.d("ADROP", "interstitial ad received ${ad.unitId}")
ad.show()
}
override fun onAdFailedToReceive(ad: AdropInterstitialAd, errorCode: AdropErrorCode) {
Log.d("ADROP", "failed to receive $errorCode")
}
override fun onAdFailedToShowFullScreen(ad: AdropInterstitialAd, errorCode: AdropErrorCode) {
Log.d("ADROP", "failed to show full screen $errorCode")
}
...
}
interstitialAd.load()
...
// call show function when the ad needs to be displayed.
interstitialAd.show(activity)
AdropInterstitialAd interstitialAd = new AdropInterstitialAd(context, "YOUR_UNIT_ID");
interstitialAd.setInterstitialAdListener(new AdropInterstitialAdListener() {
@Override
public void onAdReceived(@NotNull AdropInterstitialAd ad) {
Log.d("ADROP", "interstitial ad received " + ad.unitId);
ad.show();
}
@Override
public void onAdFailedToReceive(@NotNull AdropInterstitialAd ad, @NotNull AdropErrorCode errorCode) {
Log.d("ADROP", "failed to received " + errorCode);
}
@Override
public void onAdFailedToShowFullScreen(@NotNull AdropInterstitialAd ad, @NotNull AdropErrorCode errorCode) {
Log.d("ADROP", "failed to show full screen " + errorCode);
}
...
});
interstitialAd.load();
...
// call show function when the ad needs to be displayed.
interstitialAd.show(activity);
Destroy
When you are done showing your AdropInterstitialAd, you should destroy it so that the ad is properly garbage collected.
interstitialAd.destroy()
interstitialAd.destroy();
Last updated