Admob Configuration

Pa
Last updated 3 months ago

How to Integrate Google AdMob in your App

Introduction

AdMob is a multi platform mobile ad network that allows you to monetize your android app. By integrating AdMob you can start earning right away. It is very useful particularly when you are publishing a free app and want to earn some money from it.

Integrating AdMob is such an easy task that it takes not more than 5mins. In this article we’ll build a simple app with two screen to show the different types of ads that AdMob supports.

Creating Ad Units

NOTE : AdMob admin interface changes quite often. The below steps to create Ad Unit IDs might differ time to time.

Want to know more?? Follow this link - https://developers.google.com/admob/android/quick-start

1. Sign into your AdMob account.

2. Create a new App by giving the package name of the app you want to integrate AdMob. Once the App is created, you can find the APP ID on the dashboard which looks like ca-app-pub-XXXXXXXXX~XXXXXXXXX.

3. Select the newly created App and click on ADD AD UNIT button to create a new ad unit.

4. Select the ad format and give the ad unit a name.

5. Once the ad unit is created, you can notice the Ad unit ID on the dashboard. An example of ad unit id look like ca-app-pub-10XXXXXXXX/XXXXXXXXXXX

Create ad unit for banner ads

After creating banner ad unit and interstitial ad unit you have to place you adUnit id in string.xml file.

app > res > values > string.xml

string.xml

How to remove AdMob Ads from App?

Remove InterstitialAd

Go to app > java > com.itechnotion.wpnews > Home > HomePageactivity

HomepageActivity.java

remove below code

if (isAdd==true) {
InterstitialAd();
}else {
}

Remove BannerAd

Go to app > java > com.itechnotion.wpnews > Home > HomeFragment

remove Banner() from onCreateView method.

HomeFragment.java

app > java > com.itechnotion.wpnews > AlldataFragment

remove Banner() from Initialization method.

AlldataFragment.java