0

我目前正在开发一个应用程序,并决定尝试 Admob 广告。

不幸的是,在遵循 Admob 的指南(非常简单,做得很好)之后,无论是在模拟器上还是在手机(HTC Desire)上运行,我都没有收到广告。奇怪的是,广告已经展示了几次(我的意思是只有几次),在数百次尝试中。检查我在 Admob 上的帐户,我发现这个应用程序有 6000 个请求。

我从一张白纸开始了一个新的应用程序,没有任何变化。

有什么线索吗?

这是我到目前为止所做的:

  • 添加了 Admob 的库 JAR。

  • 在我的清单中添加了这些(使用正确的 ID):

    meta-data android:value="axxxxxxxxxxxxx" android:name="ADMOB_PUBLISHER_ID" /  
    uses-permission android:name="android.permission.INTERNET" /
    
  • 使用以下内容创建了一个attrs.xml文件res/values

    ?xml version="1.0" encoding="utf-8"?>  
    resources>  
    declare-styleable name="com.admob.android.ads.AdView">  
    attr name="backgroundColor" format="color" />  
    attr name="primaryTextColor" format="color" />  
    attr name="secondaryTextColor" format="color" />  
    attr name="keywords" format="string" />  
    attr name="refreshInterval" format="integer" />  
    /declare-styleable>  
    /resources>
    
  • 在我的布局中添加了以下内容 ( RelativeLayout):

    • 在 RelativeLayout 行下方,使用正确的应用程序名称而不是 xxxx:

      xmlns:app="http://schemas.android.com/apk/res/com.me.xxxx"
      

      和:

      com.admob.android.ads.AdView  
      android:id="@+id/ad"  
      android:layout_width="fill_parent"  
      android:layout_height="wrap_content"  
      android:layout_alignParentBottom="true"  
      app:backgroundColor="#000000"  
      app:primaryTextColor="#FFFFFF"  
      app:secondaryTextColor="#CCCCCC"  
      />
      
  • 由于上述方法不起作用,我尝试了以下方法,但也没有成功:

    AdView example_adview = (AdView) findViewById(R.id.ad);
    example_adview.setVisibility(AdView.VISIBLE);
    example_adview.requestFreshAd();
    
4

1 回答 1

1

您是否尝试过添加

AdManager.setTestDevices( new String[] {                 
        AdManager.TEST_EMULATOR 
});

到要显示广告的活动类?

如果您使用手机进行调试,您还需要将手机的 ID 添加到数组中。

于 2010-10-20T12:48:35.333 回答