android - Admob 横幅未在真实设备中显示

标签 android admob ads adsense

在 Google 商店中使用我的应用程序 2 周后,我意识到横幅没有在真实设备中显示。当我用 Android Studio 虚拟设备测试它时,它很好。

这是与我的 MainActivity 中的横幅相关的代码:

AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest request = new AdRequest.Builder().build();
    mAdView.loadAd(request);

和布局:
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/gray_background">
    <com.flaviofaria.kenburnsview.KenBurnsView
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <LinearLayout
        android:layout_marginTop="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context="misc.songbox.Search"
        android:orientation="vertical">

        <com.google.android.gms.ads.AdView

            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/bannerAd">

        </com.google.android.gms.ads.AdView>

        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/listView"
            android:dividerHeight="0dp"
            />

    </LinearLayout>
</RelativeLayout>

最佳答案

使用此 xml 代码...

<com.google.android.gms.ads.AdView

        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/bannerAd">

    </com.google.android.gms.ads.AdView>

关于android - Admob 横幅未在真实设备中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44102226/

相关文章:

android - GoogleAccountCredential 重用授权 - Google 云端硬盘

java - 如何检查服务是否在 Android 8 (API 26) 上运行?

Linkedin API 无法创建事件

android - iOS/Android 是否可以知道用户何时触摸了广告?

android - 安装应用形式奖励视频后如何奖励用户 - android

Android:可以将相同的位图设置为两个ImageView吗?

android - CSS Calc 在 Chrome 中有效,但在 Android 4.4.2 上的 Phonegap 应用程序中无效

android - 为什么我的 Admob 奖励视频广告一次又一次加载失败?

java - 每个选项卡上的 adview(tabhost、admob)

android - AdMob "Not enough space to show ad"错误