Admob没有显示

时间:2013-04-16 16:57:29

标签: android admob

我正在尝试在我开发的应用中添加AdMob。

这是我的xml:

<LinearLayout 
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical"
    tools:context=".MainActivity" >
    <com.google.ads.AdView
        xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/ad"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        googleads:adSize="BANNER"
        googleads:adUnitId="###########" />
</LinearLayout>

我在onCreate方法中的代码:

//ads
AdView adView = (AdView) findViewById(R.id.ad);
adView.loadAd(new AdRequest());

LogCat提供了类似的内容:

Received ad url <url: http://googleads.....

所以它以某种方式工作,但在我的应用程序上,我从来没有看到任何横幅。你知道发生了什么吗?

我已经按照本教程: http://androcode.es/2012/05/monetizando-nuestras-apps-admob-en-android/http://developer.android.com/intl/es/training/monetization/ads-and-ux.html

一样

但没有运气。

修改 哦,忘了提到我在清单中有这两行:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

例如,如果我删除任何这些权限,则AD SHOWN 表示缺少某些权限。所以我认为布局很好。

EDIT2: 还尝试将此代码设置为测试目的,并且它发生的完全相同:

adRequest.addTestDevice("#############");

EDIT3: 我读过第一次可能需要很长时间。需要多长时间?因为我等了大约30分钟。 logcat会说它收到了广告吗?

1 个答案:

答案 0 :(得分:0)

解决了它。显然它在模拟器上工作: 在xml文件中添加了这个:

googleads:loadAdOnCreate="true"