AI-generated Key Takeaways
-
This page highlights the differences in loading and showing an interstitial ad between the current and Google Mobile Ads SDK (beta).
-
The examples demonstrate the code for loading an interstitial ad in both the current and Google Mobile Ads SDK (beta) using Kotlin and Java.
-
The examples demonstrate the code for showing an interstitial ad, which remains consistent between the current and Google Mobile Ads SDK (beta) in both Kotlin and Java.
This page covers the differences in loading and showing an interstitial ad between the current and Google Mobile Ads SDK (beta).
Load an ad
The following examples load an interstitial ad:
Current |
KotlinInterstitialAd.load( this@InterstitialActivity, "AD_UNIT_ID", AdRequest.Builder().build(), object : InterstitialAdLoadCallback() { override fun onAdLoaded(ad: InterstitialAd) { // Called when an ad has loaded. ad.fullScreenContentCallback = object : FullScreenContentCallback() { } interstitialAd = ad } override fun onAdFailedToLoad(loadAdError: LoadAdError) { // Called when ad fails to load. } } ) JavaInterstitialAd.load( this, "AD_UNIT_ID", new AdRequest.Builder().build(), new InterstitialAdLoadCallback() { @Override public void onAdLoaded(@NonNull InterstitialAd ad) { // Called when an ad has loaded. ad.setFullScreenContentCallback(new FullScreenContentCallback() {}); interstitialAd = ad; } @Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { // Called when ad fails to load. } } ); |
Google Mobile Ads SDK (beta) |
KotlinInterstitialAd.load( AdRequest.Builder("AD_UNIT_ID").build(), object : AdLoadCallback<InterstitialAd> { override fun onAdLoaded(ad: InterstitialAd) { // Called when an ad has loaded. ad.adEventCallback = object : InterstitialAdEventCallback { } interstitialAd = ad } override fun onAdFailedToLoad(loadAdError: LoadAdError) { // Called when ad fails to load. } } ) JavaInterstitialAd.load( new AdRequest.Builder("AD_UNIT_ID").build(), new AdLoadCallback<InterstitialAd>() { @Override public void onAdLoaded(@NonNull InterstitialAd ad) { // Called when an ad has loaded. ad.setAdEventCallback(new InterstitialAdEventCallback() {}); interstitialAd = ad; } @Override public void onAdFailedToLoad(@NonNull LoadAdError adError) { // Called when ad fails to load. } }); |
Show an ad
The following examples show an interstitial ad:
Current |
KotlininterstitialAd?.show(this@InterstitialActivity) JavainterstitialAd.show(this); |
Google Mobile Ads SDK (beta) |
KotlininterstitialAd?.show(this@InterstitialActivity) JavainterstitialAd.show(this); |