Free Shipping

Secure Payment

easy returns

24/7 support

  • Home
  • Blog
  • Best Way to Monetize Android Apps using AdMob

Best Way to Monetize Android Apps using AdMob

 July 14  | 0 Comments

What is AdMob?

AdMob by Google is a mobile Advertising platform. It is an easy way to monetize our app by advertisement. We can use it to generate the revenue from our app by publishing it.
We can show various types of ads in our app by using AdMob. Like Banner Ads, Interstitial Ads, Video Ads and Native Ads.
It is very easy to integrate AdMob in our app by creating AdMob account and generating Ad Unit Id. We can create one or more Ad Unit Id, depending upon the type and number of Ads.
So, let’s see how we will integrate AdMob in our Application and what are the steps for it.

How to Create Ad Unit Id’s

Before creating this application, we must generate a unique identifier id for our ad.
Here we will use Banner Ad and Interstitial Ad in our application.
Banner Ad: It takes a portion of our screen. We can place it at the top, bottom or middle anywhere, depending upon the requirement of the application.
Interstitial Ad: It takes the full screen of our device which means it will block the UI of application and comes over it.
So, there are some steps to generate the Ad Unit Id i.e.
⦁ Sign In into your AdMob account.
⦁ After successfully creating your account click on Monetize apps.
⦁ Then add your application manually. Give the application name and platform Android.
⦁ After this, it will generate the App Id.
See the below figure.

Get Skilled in Android DevelopmentHere, we can see very well that it generates the App id. After this, we must select an Ad format which is the type of ad you want to show in your application.
Here we fill all the details ad unit name etc. in Banner Ad and then in Interstitial Ad. Both having different Ad Unit Id’s

Like this, we can see the Ad unit id of Interstitial Ad. After generates, it looks like this.
Now, we have two different Ad id’s one for Banner and another for Interstitial.
Let us see how we use both in this application.


Example with code

⦁ Create an Application AdMobExampleAndroid.
⦁ Add the dependency in build.gradle file.

dependencies {
compile ''

⦁ Now Add the permissions in AndroidManifest.xml file and other properties like google play services version etc.

<manifest ….
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
android:value="@integer/google_play_services_version" />
<!-- Include the AdActivity configChanges and theme. -->
android:theme="@android:style/Theme.Translucent" />

Requirements, activity_main.xml, InterstitialAdActivity, strings.xml.
So, these are the files where we have to work. Firstly, we will add the Ad Unit id’s in strings.xml file.
Add the code here for both Banner and Interstitial Ad.

<string name="banner_id">ca-app-pub-2474599530544069/3159981630</string>
<string name="interstitial_id">ca-app-pub-2474599530544069/6113448034 </string>

This is our main layout file. Here we will show the welcome message, a button for launching InterstialAdActivity and AdView to display a Banner.
Add the code here:

 <Button android:id="@+id/btn_fullscreen_ad"
     android:text="Show FullScreen Ad"

Here, we can see that we added the banner at the bottom side of the screen.
This is our Main Activity here we will take the reference of AdView and by creating instance of AdRequest load the ad into AdView also we set adListener on them to let the user know about the events.

private AdView mAdView;
private Button btnFullscreenAd;

Add the code in onCreate(){..}:

mAdView = (AdView) findViewById(;
AdRequest adRequest = new AdRequest.Builder()
mAdView.setAdListener(new AdListener() {
    public void onAdLoaded() {
        Toast.makeText(getApplicationContext(), "Ad is loaded!", Toast.LENGTH_SHORT).show();
    public void onAdClosed() {
        Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show();
    public void onAdFailedToLoad(int errorCode) {
        Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show();
    public void onAdLeftApplication() {
        Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show();
    public void onAdOpened() {
        Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show();
btnFullscreenAd = (Button) findViewById(;
btnFullscreenAd.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        startActivity(new Intent(MainActivity.this, InterstitialAdActivity.class));

Here it shows the live ads, but as a testing purpose during development, we can test it by using device id. We can get this with the help of logCat just take your device id and add it. Like this

AdRequest adRequest = new AdRequest.Builder()

Here we will display the full-screen ad when the user comes in this activity. It will directly show the ad.

InterstitialAd mInterstitialAd;

Add the code here:

mInterstitialAd = new InterstitialAd(this);
 // set the ad unit ID
 AdRequest adRequest = new AdRequest.Builder()
 // Load ads into Interstitial Ads
 mInterstitialAd.setAdListener(new AdListener() {
 public void onAdLoaded() {
private void showInterstitial() {
 if (mInterstitialAd.isLoaded()) {;

Same we can do for InterstialAd also. By adding device id instead of live ads.


Download Code: GitHub


This is a simple example of AdMob on how to implement it in our application. As we discussed we can show the different type of ads in our app and place it accordingly. So by using this we can also earn money by publishing the apps. It is new for a mobile advertising platform. There are some simple steps to generate the Ad Unit id for an application. we can monetize as many apps as we discussed and generate one or more Ad unit id’s for the same application.

Keep visiting for more updates on the courses.