在我的应用程序在谷歌商店2周后,我意识到 Banner 没有在真实设备中显示 . 当我用Android studio虚拟设备测试时,它很好 .
这个与我的MainActivity中的 Banner 相关的代码:
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>
2 回答
使用这个xml代码......
如果您能够加载测试广告但不能加载实时广告,则会发现您的AdMob帐户存在问题 . 您能确保正确设置付款系统和/或验证您的个人识别码吗?如果未完成,则不会从您的帐户投放实时广告 .