How To Add AdMob Ads in Android App – Banner Ads

In this tutorial you will see how to:

  • add banner ads in your Android App
  • add events in the ad’s lifecycle
  • use Smart Banners

What are banners ads?

Banners ads are rectangular image or text ads that  occupy a spot within an app’s layout. They stay on screen during the time that the users are interacting with the app and refresh automatically after a period of time.

First you will add the “AdView” to the layout!

Never forget to test with test ads only, don’t ever use the production ads for testing purposes, as you might get banned by AdMob for suspicious activity

The ad is initialized in the “onCreate” method of the main activity, then we create an AdRequest and build the add. Eventually, the ad is loaded into the adView.

Further, you can customize the behavior of the add by adding a number of events in the ad’s lifecycle like: loading, opening and/or closing. All of these events are added through the AdListener class.

You add the listeners to the end of the Main.activity and then you can add the logic to each event (in our video example, we just toast a message).

Banner ads come in different sizes (320×50, 320×100, 300×250, 468×60, 728X90 etc) and can be called using their AdSize constants (BANNER, LARGE_BANNER, MEDIUM_RECTANGLE, FULL_BANNER etc…).

Note: when you go into production, if your ads don’t appear immediately and you are sure that you have set up everything correctly, then be patient and wait, as it takes a while for the ads to start populating.

The video tutorial is made utilizing the information from the link below: https://developers.google.com/admob/android/banner

Let me hear of your thoughts and comments in the section below.

Leave a Comment