Admob Banner Ads

 



Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.

This guide shows you how to integrate banner ads from AdMob into an Android app using Sketchware Pro. In addition to blocks and instructions, it also includes information about sizing banners properly and links to additional resources.

Prerequisites

• Download the latest admob sdk(local Libraries), components and blocks here.

NOTE:

Make sure you download the blocks,
components and Local Libraries.

Add AdView to the layout

The first step towards display a banner ad is by adding the banner ad component in your project, the illustration below shows how you can add an AdMob banner ad component.


NOTE: you can only add these components when you have added all the admob Local Libraries

There are basically two ways we can use to show or display an advert i.e 
- Inflating the Adview using XML.
- Inflating the Adview programmatically.

For now we would be considering the second method i.e Inflating the Adview programmatically,the illustration below shows how you can inflate an AdMob Adview to a layout using blocks.




Warning: Make sure you set the ad size and ad unit ID in the same manner (i.e. set both in XML or both programmatically).

Test Ads

When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.

The easiest way to load test ads is to use our dedicated test ad unit ID for Android banners:

ca-app-pub-3940256099942544/6300978111

It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.

For more information about how the Mobile Ads SDK's test ads work, see Test ads.


Once the Adview is in place the next step is to load an ad. The illustration below shows how you can load an ad in your activity ON CREATE, these method shows or displays your banner advert



After you have loaded your AdMob banner ad you would need to setup listeners to handle events to customize the behavior of your ad, you can hook onto a number of events in the ad's lifecycle: loading, opening, closing, and so on. You can listen for these events through the AdListener class. The illustration below shows how you can add event listeners.


NOTE:

- Make sure you download the blocks, components and localLibraries here.
- For better understanding, you can refer to my YouTube Tutorial.
- Kindly subscribe to my YouTube channel here and make sure you join my Telegram channel to get Updates on my tutorials and projects Subscribe here.

Enjoy the tutorial

Comments

Popular posts from this blog

Implementing Google Admob Mobile Ads SDK (Android) in Sketchware without using Sketchware Admob Libraries