Skip to content Skip to sidebar Skip to footer

Because Admob Interstitial Ads Won't Display?

What is the error?Because admob interstital ads won't display? public class MainActivity extends Activity implements AdListener { private InterstitialAd interstitial;

Solution 1:

Just follow below example

import com.google.android.gms.ads.*;

publicclassBannerExampleextendsActivity {

private InterstitialAd interstitial;

@OverridepublicvoidonCreate(Bundle savedInstanceState) {

     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);

// Create the interstitial.
     interstitial = newInterstitialAd(this);
     interstitial.setAdUnitId(MY_AD_UNIT_ID);

// Create ad request.AdRequestadRequest=newAdRequest.Builder().build();

// Begin loading your interstitial.
     interstitial.loadAd(adRequest);
}
//Invoke displayInterstitial() when you are ready to display an interstitial.publicvoiddisplayInterstitial() {

    if (interstitial.isLoaded()) {
        interstitial.show();
      }
}
}

Solution 2:

Your should add the .build() at the end of the creation of the AdRequest.

// Create ad requestAdRequestadRequest=newAdRequest().build();

Post a Comment for "Because Admob Interstitial Ads Won't Display?"