Admob


 

  1. Banner
  2. Full Screen(InterstitialAds)

 

Steps to do before:
  1. Sign up as an Admob Publisher here.
  2. Identify your publisher ID on the top right of your dashboard, starts with pub-xxxxxxxxxx.
  3. Open the Monetize tab and create an ad unit for your application. You should be able to see your ad unit after selecting an app on your left panel.
  4. An Ad Unit ID is a unique identifier given to the places in your application where ads are displayed. If you had an app with two activites, for example, each displaying a banner, you’d have two ad units, each with its own ID. Your Ad Unit ID starts with ca-app-pub-xxxxxxxxxxxxxx/xxxxxxx
  5. Download the Google Play Services Library using the Android SDK Manager.
  6. For Eclipse:
    a. Now you need to import Google Play services library into your app current workspace.
    File >> Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it. The Google Play services SDK is saved in your Android SDK environment at /extras/google/google_play_services/.
    b. Add Google Play services to Your App
    ->Right-click your App project -> Select Properties -> In the Properties window select Android, Under the Library section click Add -> Select google-play-services-lib and Click OK
    For Android Studio: compile 'com.google.android.gms:play-services:7.0.0'

 

1. Banner

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> values-> string.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

admob_banner

Download SourceCode

 

2. Full Screen(InterstitialAds)

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> values-> string.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

admob_fullscreen admob_fullscreen2

Download SourceCode