3

我试图在我的应用程序上设置 admob 并且它无法正常工作它在你必须输入用户 ID 以使 admob 服务工作的行出现错误:(

package com.google.example.ads.fundamentals;

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

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

/**
 * 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);

error here
// 创建一个广告。adView = new AdView(this, AdSize.BANNER, a1515* * **** );

    // 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();
  }
}
4

1 回答 1

0


我认为问题是 AdView 类中的第三个参数必须是字符串

尝试将其更改为:

 adView = new AdView(this, AdSize.BANNER, "a1515******");

我希望这对你有帮助

干杯,

于 2013-03-28T21:05:44.863 回答