Eri*_*vik 10 android listview admob
我在Android应用中使用AdMob视图,但我无法在应用中获得任何广告.
作为参考,我已经添加了查看到ListView由达恩·戴尔解释这里
编辑:我正在使用GoogleAdMobAdsSdk-4.1.1.Google AdMob Ads SDK 4.1.0版的发行说明中说:
"... - 添加了对AdRequest.addTestDevice()和AdRequest.setTestDevices()的支持.请注意,AdRequest.setTesting()现已弃用...."
这是广告插入我的ListView的方式:
public View getView(int position, View convertView, ViewGroup parent) {
// Some other code
// Reusing convertView etc.
AdView adView =
new AdView((Activity) getContext(), AdSize.BANNER,
"/xxxxxx/ca-pub-xxxxxxx/my_ad_unit");
for (int i = 0; i < adView.getChildCount(); i++) {
adView.getChildAt(i).setFocusable(false);
}
adView.setFocusable(false);
float density = getContext().getResources().getDisplayMetrics().density;
int height = Math.round(50 * density);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(
AbsListView.LayoutParams.FILL_PARENT, height);
adView.setLayoutParams(params);
AdRequest request = new AdRequest();
request.addTestDevice("xxxxxxxxxxxxxxxxx");
adView.loadAd(request);
// other stuff
// returning convertView
}
Run Code Online (Sandbox Code Playgroud)
我还在adview中添加了一个AdListener,并在每个loadAd上调用onFailedToReceiveAd回调方法:
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
Log.d(TAG, "AdMob in list failed to receive ad: " + arg1.name());
}
Run Code Online (Sandbox Code Playgroud)
在logcat中,我收到以下消息:
08-17 15:22:18.065: AdMob in list failed to receive ad: NO_FILL
Run Code Online (Sandbox Code Playgroud)
有谁能告诉我这个错误代码是什么意思?
回答这个问题:
当 AdMob/DFP 后端没有剩余广告资源可供投放时,AdMob 会返回 NO_FILL。
首先,这意味着我请求尺寸为 AxB 的广告,但后端没有该尺寸的广告可供展示。您请求的尺寸必须在 AdMob/DFP 后端系统中留有库存,这一点很重要。
其次,他们的 API 规定,第一次向特定广告单元请求广告时,预计广告开始投放前最多两分钟。我不知道是不是因为我不在美国驻扎,但这两分钟对我来说常常变成至少20分钟,甚至几个小时。
归档时间: |
|
查看次数: |
14487 次 |
最近记录: |