Esta página apresenta as diferenças no carregamento e na exibição de um anúncio intersticial entre o SDK de anúncios para dispositivos móveis do Google (Beta) e o atual.
Carregar um anúncio
Os exemplos a seguir carregam um anúncio intersticial:
Atual |
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. } } ); |
SDK dos anúncios para dispositivos móveis do Google (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. } }); |
Mostrar um anúncio
Os exemplos a seguir mostram um anúncio intersticial:
Atual |
KotlininterstitialAd?.show(this@InterstitialActivity) JavainterstitialAd.show(this); |
SDK dos anúncios para dispositivos móveis do Google (Beta) |
KotlininterstitialAd?.show(this@InterstitialActivity) JavainterstitialAd.show(this); |