To monetize the android apps, Google provided a mobile ad network called AdMob to show the ads in applications. If we want to earn the revenue from our android apps, then AdMob platform is the perfect solution to easily integrate the ads in our android apps.
Different Types of Ad Formats
AdMob network provides a different types of ad formats, so we can choose the ads which best fits to our app’s user experience. Following are the different types of ad formats available for android apps.
- Banner Ads
- Interstitial Ads
- Rewarded Video Ads
Banner Ads
Banner ads are rectangular image or text ads that occupy a spot within an app's layout. 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.
Interstitial Ads
Interstitial Ads are full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or just after completing a task.
Rewarded Video Ads
Rewarded video ads are full screen video ads and it rewards the users for watching the ads.
To earn the revenue by integrating the Google AdMob ads in android applications, first we need to register an account in AdMob, create ad units in AdMob and we need to integrate Google Mobile Ads SDK into an app.
Create Ad Units in AdMob
To create an ad units in AdMob, first we need to Create an Account in AdMob and need to register our app in AdMob network.
Follow below steps to register and create ad units in AdMod network.
- First Sign into AdMob network and click on Apps in the sidebar.
- In Apps window, click on Add App or Add Your First App button. A new dialog box will appear and it will ask whether your app published or not. In case if your app already published in play store click ‘YES’ otherwise ‘NO’.
- In case if you select YES option, Enter the name of app, click Search and click on Add beside the app we want to add.
- In case if you select NO, Enter the name of app to create, Select the platform either iOS or Android and click Add button.
- After adding our app to AdMod, it will create App ID for our app. Now Click Create Ad Unit to create an ad unit for this app or click I'll Do it Later to exit the page.
- In case if you click I’ll Do it Later it will take to you to dashboard page. Now select the newly created App, click on Ad Units tab and create new Ad Unit to display ads.
- Now select Ad Format, Give the Name of Ad Unit and click Create Ad Unit.
Once we are done with creation of Ad Unit that will show in our Dashboard like as shown below.
In case, if you want to create more ad units, just click on ADD AD UNIT button and create it based on your requirements.
Now we will see how to integrate AdMob Ad Units in our android application to show the ads with example.
Import Mobile Ads SDK
To start integrating AdMob ads in our android application, we need to import the Google Mobile Ads SDK with Gradle dependency that points to Google’s Maven repository, for that open your app à Gradle Scripts à build.gradle (project) and add maven repository in allprojects section like as shown below.
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
Now we need to add google play services to our application, for that open your app à Gradle Scripts à build.gradle (Module: app) and add following google play services compile statement to the dependencies{} section.
dependencies {
...
compile 'com.google.android.gms:play-services-ads:11.8.0'
...
compile 'com.google.android.gms:play-services-ads:11.8.0'
...
}
}
The above one instructs Gradle to pull the latest version of the Mobile Ads SDK. Once you are done with adding required dependencies, save the file and perform a Gradle sync.
Initialize Mobile Ads
To load the ads in our app, we need to initialize Mobiles Ads SDK by calling MobileAds.Initialize() with our AdMob App ID.
Following is the example of calling the initialize() method in an activity.
package com.tutlane.admobexample;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import com.google.android.gms.ads.MobileAds;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-3214000786576152~8215460912");
}
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-3214000786576152~8215460912");
}
}
We are done with importing Mobile Ads SDK and we are ready to implement and ads in our application.
Select an Ad Format
Google AdMob provided a different type of ad formats (Banner, Interstitial and Rewarded), we need to choose the one that best fits to our app’s user experience.
Banner Ads
Banner ads are rectangular image or text ads that occupy a spot within an app's layout. 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.
To know more about Banner Ads implementation in Android applications, check this Android Banner Ads with Examples.
Interstitial Ads
Interstitial Ads are full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or just after completing a task.
To know more about Interstitial Ads implementation in android applications, check this Android Interstitial Ads with Examples.
Rewarded Video Ads
Rewarded video ads are full screen video ads and it rewards the users for watching the ads.
To know more about Rewarded Video Ads implementation in android applications, check this Android Rewarded Video Ads with Examples.
No comments:
Post a Comment