我在Android应用中使用AdMob视图,但我无法在应用中获得任何广告。
作为参考,我已将视图添加到ListView,如Dan Dyer here所述
编辑: 我正在使用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
}
我还在adview中添加了一个AdListener,并且在每个loadAd上都调用了onFailedToReceiveAd回调方法:
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
Log.d(TAG, "AdMob in list failed to receive ad: " + arg1.name());
}
在logcat中,我收到此消息:
08-17 15:22:18.065: AdMob in list failed to receive ad: NO_FILL
有谁能告诉我这个错误代码是什么意思?
答案 0 :(得分:3)
回答这个问题:
当没有库存时,从AdMob返回NO_FILL 在AdMob / DFP广告管理系统后端投放。
首先,这意味着我要求提供尺寸为AxB的广告,但后端没有此尺寸的广告可供展示。请求的尺寸非常重要,因为AdMob / DFP广告管理系统的后端系统会留下广告资源。
其次,他们的API声明,当您首次向特定广告单元请求广告时,您应该在广告开始投放前最多两分钟。我不知道是不是因为我没有驻扎在美国,但如果不是几个小时的话,这两分钟通常会变成至少20分钟。
答案 1 :(得分:1)
当我在测试或非测试模式下请求广告时,我收到了“无填充”回复。我该怎么办?
在“测试”和“非测试”模式下,根据服务器负载,目标广告的不可用性等各种参数,广告服务器可能会发送“无填充”响应。请在一段时间后重新加载广告,以便继续接收广告。虽然广告空间中常见的是“无填充”,但您可以通过查询向我们写信。
答案 2 :(得分:0)
这实际上意味着目前没有广告针对您的FILL请求使用AdMob。在测试模式下运行AdMob,您可以看到该广告。
request.setTesting(true);