In our activity we have to create an instance of AdRequest and then load it in AdView.

2. Interstitial Ad

For interstitial ad we don’t have to use any widget in layout xml. First make an instance of AdRequest and InterstitialAd. Set ad unit id for interstitial ad and then load the AdRequest inside InterstitialAd. We will add a listener to InterstitialAd instance and show the ad only when it is fully loaded.

Note: When you use a newly created ad unit then it will take some time to start showing ads. Instead of showing live ads you can show test ads. Just read the test ad section at the end of this tutorial.

The banner ad will be displayed automatically when activity is launched but interstitial ad will be displayed on button click.

Screenshots

How to show test ads?

AdMod doesn’t allows you to click on ads yourself. It may be possible that you will accidently click on ads. So in that case your account can be banned. To remain on safer side use test ads while you are developing the app.

You can find following line of code in andorid logcat when you will run the app.

Use AdRequest.Builder.addTestDevice(“BB93E7FC72412E6AF38CD7317F5DA20C”) to get test ads on this device

The string in double quotes is the unique id for the device in which you are running the app. To show test ads just use addTestDevice() method while making AdRequest instance. It can be done in following way.