una studio publicidad por poner para implementar google gana cuanto app aplicaciones agregar android admob interstitial

android - studio - El anuncio intersticial de Admob no se mostrará



poner publicidad en mi app android (7)

Debe esperar a que se cargue el anuncio. Solo entonces, puede llamar al método displayInterstial () , que mostraría el anuncio.

Puede registrarse para un oyente, que le permitirá saber cuándo se realiza la carga.

interstitial.setAdListener(new AdListener(){ public void onAdLoaded(){ displayInterstitial(); } });

Solía ​​mostrar el banner de AdMob en mis futuras aplicaciones, y me gustaría probar los anuncios intersticiales.

Revisé el SDK de AdMob para la implementación, y copié su fuente de ejemplo porque era exactamente lo que quería (es decir, el intersticial que se muestra cuando se inicia la actividad).

Lo probé en el emulador y en mi Galaxy, no se ha mostrado ningún anuncio.

Aquí está el código fuente:

public class Asscreed extends Activity { private InterstitialAd interstitial; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_asscreed); // Create the interstitial. interstitial = new InterstitialAd(this); interstitial.setAdUnitId("ca-app-pub-6046034785851961/xxxxxx"); // Create ad request. AdRequest adRequest = new AdRequest.Builder().build(); // Begin loading your interstitial. interstitial.loadAd(adRequest); } // Invoke displayInterstitial() when you are ready to display an interstitial. public void displayInterstitial() { if (interstitial.isLoaded()) { interstitial.show(); } } }

Las importaciones están bien y la biblioteca de Google Play Services es, por supuesto, importada.

Utilizo este ejemplo: AdMob Android Guides - Interstitial Ad .

¿Podría alguien decirme qué está mal en mi código?


Intente inicializarlo en onCreate, pero solo llame al método show () desde un evento, como hacer clic en un botón.

Puedes usar este código, los identificadores de prueba funcionan:

@Override protected void onCreate(Bundle savedInstanceState) { ... MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); //test id mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712"); //test ad mInterstitialAd.loadAd(new AdRequest.Builder().build()); btn_test.setOnClickListener(view -> { showInterstitial(); }); ... } private void showInterstitial() { if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } else { Log.d("TAG", "The interstitial wasn''t loaded yet."); } }


Lo resolví cambiando mi ID de administrador a un elemento de aplicación antiguo, como ca-app-pub-0243484158988577/9196272994


No llamaste a displayInsterstitial ().

Pero lo que debes hacer es llamar al oyente para el intersticial:

interstitial.setAdListener(this);

Luego implementará el servicio de escucha en su actividad y luego lo mostrará en AdLoaded (o algo así).


Yo tuve el mismo problema. El problema era que la actividad admob no estaba definida en el manifiesto. Asegúrese de tener una etiqueta de actividad de seguimiento en su archivo de manifiesto

<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />


esto lo hizo por mi

// Begin listening to interstitial & show ads. interstitial.setAdListener(new AdListener(){ public void onAdLoaded(){ interstitial.show(); } });

Todavía me pregunto por qué todos los chicos de Google suben el código implementando instrucciones que simplemente no funcionan después de que uno los sigue hasta el punto.


mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId("Your Interstitial Id ca-app-pub-46563563567356235/3452455"); AdRequest adRequest1 = new AdRequest.Builder() .build(); mInterstitialAd.loadAd(adRequest1); mInterstitialAd.setAdListener(new com.google.android.gms.ads.AdListener() { @Override public void onAdLoaded() { mInterstitialAd.show(); super.onAdLoaded(); } });