Android AdMob example(Android AdMob 示例)
问题描述
我从 在这里.在图片中,广告上写着AdMob Test Android Web Ad",但是当我运行代码时,我有时会看到一个实际的广告,有时什么也看不到.为什么?
I downloaded example code of an Android project featuring AdMob ads from here. In the picture, the ad says "AdMob Test Android Web Ad", but when I run the code, I sometimes see an actual ad and sometimes see nothing. Why?
推荐答案
确保在模拟器上启用了测试模式.似乎链接中的代码没有启用它的测试模式.
Ensure that test mode is enabled on emulator. Seems like the code in the link does not have it's test mode enable.
启动应用程序后,广告不会立即运行.需要几秒钟(最多 10 秒,具体取决于您的网络速度)才能接收来自 Admob 的广告.
Ads do not run immediately after launching the application. It would take a couple of seconds(up to 10secs, depending on your network speed) before being able to receive an advertisement from Admob.
在你的 onCreate() 中尝试这样的操作.
Try something like this in your onCreate().
adView = new AdView(this, AdSize.BANNER, "a9876sf98dfg");
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
layout.addView(adView);
AdRequest request = new AdRequest();
request.setTesting(false);
adView.loadAd(request);
编辑(来自评论):按照 edumobile.org/android/android-development/admob-manager 上的说明操作,但将android:id="@+id/linearLayout" 行添加到 main 的 LinearLayout 部分.xml.
EDIT (from the comments): Follow the instructions on edumobile.org/android/android-development/admob-manager, but add the line "android:id="@+id/linearLayout" to the LinearLayout part of main.xml.
这篇关于Android AdMob 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android AdMob 示例


基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01