在request.setTesting(false)时不显示admob广告

时间:2011-09-26 09:20:01

标签: android

当我放置我的酒吧ID

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

    layout.addView(adView);


AdRequest request = new AdRequest();
request.setTesting(true);

adView.loadAd(request);  

iam getting the ads but when i set it to  
request.setTesting(false)

我没有得到广告如何解决这个问题..实际问题是什么; lem?

2 个答案:

答案 0 :(得分:1)

在您的活动中使用此功能:

adview = (AdView) findViewById(R.id.adView);
AdRequest re = new AdRequest();
re.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
re.addTestDevice("xxxxxxxxxxx"); // Test Android Device
adview.loadAd(re);

在XML文件中使用它:

<com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxx"
        ads:loadAdOnCreate="true">
</com.google.ads.AdView>

答案 1 :(得分:0)

在XML中添加横幅更容易!

       <com.google.ads.AdView
  android:id="@+id/adView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  ads:adSize="BANNER"
  ads:adUnitId="xxxxxxxxxxx"
  ads:loadAdOnCreate="true"


  ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

并且仅在活动中放置

    AdView adView = (AdView)this.findViewById(R.id.adView);
    adView.loadAd(new AdRequest());