Interstitial Ads

Interstitial ads are ads which occupy the full screen of the device.

The following are the steps involved in implementing an interstitial ad through your code. First, we have to create an instance of the interstitial ad:

private InterstitialAd mInterstitialAd; 

Then, we initialize the ad in the onCreate method of the activity:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
   super.onCreate(savedInstanceState); 
   setContentView(R.layout.activity_interstitial_ad); 
   ... 
   // Create the InterstitialAd and set the adUnitId (defined in values/strings.xml). 
   mInterstitialAd = newInterstitialAd(); 
   loadInterstitial();} private InterstitialAd newInterstitialAd() { InterstitialAd interstitialAd = new InterstitialAd(this); //Set ...

Get Expert Android Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.