开发者

admob ads not displaying when request.setTesting(false)

When i place my pub id

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

and

    layout.addView(adView);


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

adView.loadAd(request);  

iam getting the a开发者_JAVA技巧ds but when i set it to  
request.setTesting(false)

i am not getting ads how to solve this.. what is the actual prob;lem?


Use this in your activity:

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

Use this in your XML file:

<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>


Add the banner in XML it is much easier !

       <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" />

and in the activity put only

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜