AdMob Manager

This is a sample activity which shows how to use AdMob Manager in your application.

Underlying Algorithm:

Basic description of algorithm in step by step form:

1.) Register or login at admob.com, and download GoogleAdMobAdsSdkAndroid-4.0.4, which contains a GoogleAdMobAdsSdk.jar file.
2.) Create a project MyAdMob.
3.) In your project’s root directory create a subdirectory lib. Copy the AdMob JAR (GoogleAdMobAdsSdk.jar) file into that lib directory.
4.) Right-click on your project from the Package Explorer tab and select Properties.
5.) Select Java Build Path from left panel and Select Libraries tab from the main window.
6.) Click on Add JARs.
7.) Select the JAR copied to the libs directory, Click OK to add the SDK to your Android project.
8.) Add some relevant permissions in AndroidManifest.xml:

 

<!--?xml version="1.0" encoding="utf-8"?-->

 

 

9.) Run the Application.

Steps to Create:

1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. MyAdMob. Enter following information:
Project name: MyAdMob
Build Target: Android 2.1
Application name: MyAdMob
Package name: com.sample.MyAdMob
Create Activity: MyAdMob

On Clicking Finish MyAdMob code structure is generated with the necessary Android Packages being imported along with MyAdMob.java. MyAdMob class will look like following:

 

package com.sample.MyAdMob;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

public class MyAdMob extends Activity
{
private static final String MY_BANNER_UNIT_ID = "a14db01ee16f245";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Lookup R.layout.main
LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);

// Create the adView
// Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
AdView adView = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);

// Add the adView to it
layout.addView(adView);

// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();
request.setTesting(true);
adView.loadAd(request);
}
}

 

 

Output –The final output:

Leave a Comment:

6 comments
Tan says October 21, 2011

How i can create my own advertising for it?

Reply
hybrid phone review says November 26, 2011

Whats up very nice site!! Man .. Excellent .. Superb .. I will bookmark your web site and take the feeds also?I’m satisfied to search out a lot of useful info right here within the put up, we’d like develop more techniques on this regard, thanks for sharing. . . . . .

Reply
Donna says January 25, 2012

Do I have to repeat steps 3-7 for *EACH* Android app I write in the future?

Reply
nitin says February 4, 2012

02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
02-04 16:31:34.881: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
02-04 16:31:34.898: ERROR/Ads(548): You must have AdActivity declared in AndroidManifest.xml with configChanges.
error will be shown in logcat ????????
resolution?

Reply
nitin says February 4, 2012

02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
02-04 16:31:34.868: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
02-04 16:31:34.881: ERROR/Ads(548): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
02-04 16:31:34.898: ERROR/Ads(548): You must have AdActivity declared in AndroidManifest.xml with configChanges.

error shown in logcat

Reply
Purdual says September 19, 2012

I have error here “”

Reply
Add Your Reply