We generally see ads regarding different products in different streams, so as in our android app we can show ads with the help of Google Admob. When you link your app with the Admob using sdk it starts showing you the ads in the place you have specified.You may customize the categories of ads you want to show on your app from admob console.

 

These ads are intended for the end user so be careful while you are integrating them use Test Ads. As it is against the Admob policy to use the live ads while testing.

 

Generally this phenomena is termed as App Monetization in this tutorial on integrating admob ads i will show you how to integrate

  1. Banner Ads
  2. Interstitial Ads

 

Banner Ads

Ad’s which are generally displayed as a small banner in top of the screen or bottom of the screen. While placing these ad’s make sure you avoid places such that no unwanted clicks occur on these views.

 

Interstitial Ads

Compared to banner ads these ad’s are displayed in full screen.So displayed these ads when ever you think is necessary same like above ads avoid unwanted clicks.

 

If you don’t have and Admob account can signup here Google Admob

Add Admob SDK to your to your project

 

build.gradle(Module:app)

 

 

build.gradle (Project)

 

 

activity_main.xml

Adding two buttons to move forward into screens where ads are displayed

 

 

MainActivity

Just code buttons to move to screens

 

now

 

activity_banner_add

 

Add a AdView using which you can display banner add make sure you place them in appropriate place avoiding unwanted clicks.

 

 

 

then initialize them

 

BannerAd

For testing purpose i am using  sample ad units   ca-app-pub-3940256099942544/6300978111

You may find them here

 

Initialize ads

adview

 

then fetching the ads for the specified adunit

 

 

loading the ad into adview

 

 

activity_interstitial

Add a button, by clicking on which you can see a Interstitial ad appearing

 

 

Interstitial

 

Initialize Interstitial ads

 

 

adding adunit there is a different adunit for both Banner and Interstitial Ad mat refer link for sample adunits

 

 

you need to load ad before it’s been displayed

 

then load the ad on button click

 

AdListener can be used to make any functionality if required during the ads are being displayed or after being displayed

 

After an ad is displayed you need to load the next ad

 

 

 

 

 

Manifest

Add internet and access network permissions to you manifest file

 

 

 

For more info visit Admob

 

Share and like this tutorial if you like it.

Show Buttons
Hide Buttons
Read previous post:
Android Send SMS Using Intent || Send SMS from app

Close