android admob id

i am very new to the android app development, and i have just almost completed one app finally, and now i am trying to add admob to the app in order to show the ad undernearth.

i have installed that GoogleAdMobAdsSdkAndroid.zip version 6.1.0 and also downloaded the example from google at https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals?hl=zh-CN and there is one line

adView = new AdView(this, AdSize.BANNER, AD_UNIT_ID_GOES_HERE);

that has bug AD_UNIT_ID_GOES_HERE highlighted.

  1. is that i must replace the above AD_UNIT_ID_GOES_HERE by registering and getting an admob account? I have not registered any admob account yet.
  2. Is that then i cannot test and preview about the ad if i have no true admob account? are there any ID available solely for testing purposes before i really register for a real one?

The java code is solely copied from the above google website and pasted as follows. android manifest and xml are also same as those in the google example.

package com.google.example.ads.fundamentals;

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;

/**
 * A simple {@link Activity} that embeds an AdView.
 */
public class BannerSample extends Activity {
/** The view to show the ad. */
  private AdView adView;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Create an ad.
    adView = new AdView(this, AdSize.BANNER, AD_UNIT_ID_GOES_HERE);

    // Add the AdView to the view hierarchy. The view will have no size
    // until the ad is loaded.
    LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
    layout.addView(adView);

    // Create an ad request. Check logcat output for the hashed device ID to
    // get test ads on a physical device.
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

    // Start loading the ad in the background.
    adView.loadAd(adRequest);
  }

  /** Called before the activity is destroyed. */
  @Override
  public void onDestroy() {
    // Destroy the AdView.
    if (adView != null) {
      adView.destroy();
    }

    super.onDestroy();
  }
}

Answers


Just make yourself an account. It's free!

You can't show ads without an publisher id.


Use this adunit id for testing ads:adUnitId="a15391a0507f390"


Need Your Help

Low memory warning when using AVCaptureStillImageOutput

iphone memory-management avcapturesession

I am observing memory burst of 25MB at [self setImageData:[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]];

SSRS - Custom Code

ssrs-2008

I'm trying to access a REST service from a function written in the custom code of a report. I don't want to move that code into a separate assembly so the problem is around the custom code, please ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.