Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android问题中的Admob_Android_Admob - Fatal编程技术网

Android问题中的Admob

Android问题中的Admob,android,admob,Android,Admob,我目前正在开发一个应用程序,并决定尝试Admob广告 不幸的是,在遵循Admob的指南(非常简单,做得很好)之后,我没有收到任何广告,无论是在模拟器上还是在我的手机上(HTC Desire)。奇怪的是,这则广告已经在数百次尝试中展示了好几次(我真的是说只有几次)。在Admob上查看我的帐户,我发现有6000个来自此应用程序的请求 我开始了一个新的应用程序,从无到有,没有任何变化 有什么线索吗 这就是我到目前为止所做的: 添加了Admob的库JAR 在我的清单中添加了这些(使用正确的ID):

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

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

我开始了一个新的应用程序,从无到有,没有任何变化

有什么线索吗

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

  • 添加了Admob的库JAR

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

  • res/values
    中创建了包含以下内容的
    attrs.xml
    文件:

    ?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();
    
您是否尝试添加

AdManager.setTestDevices( new String[] {                 
        AdManager.TEST_EMULATOR 
});
要显示广告的活动类


如果您正在使用手机进行调试,还需要将手机ID添加到阵列中。

谢谢您的回答。使用测试模式,我成功地在模拟器和设备上显示了广告。我的问题是,当我把这些测试线拿出来的时候,是否真的会出现在我为其他人的最终申请中?我有种感觉,他们每100次才出现一次。我在logcat中得到的消息是“没有填充。服务器回答说没有可用的广告”。这正常吗?此问题使用的是attrs.xml,这可能意味着它使用的是Admob 4.0.4或更早版本。4.1.0中描述了一些更改(查找Tim的帖子)。
AdManager.setTestDevices( new String[] {                 
        AdManager.TEST_EMULATOR 
});