content: package com.androidavanzado.googleadmob;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  import com.google.android.gms.ads.AdListener;
  import com.google.android.gms.ads.AdRequest;
  import com.google.android.gms.ads.AdView;
  import com.google.android.gms.ads.MobileAds;
  
  public class MainActivity extends AppCompatActivity {
      private AdView banner;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          MobileAds.initialize(this, "ca-app-pub-3850129240631389~9209579640");
  
          banner = findViewById(R.id.adViewBanner);
          // Solicitud de anuncio para mostrar en el banner
          AdRequest adRequest = new AdRequest.Builder().build();
          // Asociar la solicitud al banner
          banner.loadAd(adRequest);
          banner.setAdListener(new AdListener() {
              @Override
              public void onAdLoaded() {
                  // Code to be executed when an ad finishes loading.
              }
  
              @Override
              public void onAdFailedToLoad(int errorCode) {
                  // Code to be executed when an ad request fails.
              }
  
              @Override
              public void onAdOpened() {
                  // Code to be executed when an ad opens an overlay that
                  // covers the screen.
              }
  
              @Override
              public void onAdLeftApplication() {
                  // Code to be executed when the user has left the app.
              }
  
              @Override
              public void onAdClosed() {
                  // Code to be executed when the user is about to return
                  // to the app after tapping on an ad.
              }
          });
      }
  }
  