AdMob API 和关键字
有人在设置关键字或搜索查询时设法从 AdMob 服务器获取相关广告吗?我的应用程序在 Android 上运行,并且我设法从 AdMob 服务器检索广告。
我尝试了几种解决方案,但它们似乎不起作用。
解决方案 1:使用 AdView 类中的方法 setKeywords( String keywords )
或 setSearchQuery( String searchQuery )
,然后调用 requestFreshAd ()
。当前正在进行请求时,对 requestFreshAd()
的调用会在 log 中生成以下消息:
“WARN/AdMobSDK(2541):忽略 requestFreshAd(),因为我们 现在已经请求广告了。”
。
因此,我尝试在没有请求正在进行时调用 requestFreshAd()
,但它不再起作用。
解决方案 2:< /strong> 在 XML 布局中,使用 AdView 元素上的属性 myapp:keywords="myKeywords"
该属性先前已在 attrs.xml 文件中声明。
Does anyone manage to get relevant advertisement from AdMob server when setting keywords or search query ? My application runs on Android and I manage to retrieve ads from the AdMob server.
I try several solutions but they do not seem to work.
Solution 1: use the methods setKeywords( String keywords )
or setSearchQuery( String searchQuery )
from the AdView class and then, call requestFreshAd()
. When a request is currently in progress, a call to requestFreshAd()
generate the following message in log :
"WARN/AdMobSDK(2541): Ignoring requestFreshAd() because we are
requesting an ad right now already."
.
Thus, I try to call requestFreshAd()
when no request are in progress but it doesn't work anymore.
Solution 2: In the XML layout, use the attributes myapp:keywords="myKeywords"
on the AdView element. This attributes is previously declared in the attrs.xml file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ADMob SDK将根据设置的刷新率自动请求新添加。我认为默认是 60 秒。因此,您根本不必调用
requestFreshAd()
。从 Eclipse 运行您的应用程序,转到添加所在的 Activity,然后观察 logcat 窗口。您会定期看到根据刷新率设置自动获取添加内容。您可以在 http://www.admob.com/my_sites 上更改刷新率,然后点击“管理”应用程序上的“设置”和“应用程序设置”。此外,您还可以使用布局 XML 文件中 AdView 元素上的
refreshInterval
属性简单地设置刷新间隔。ADMob SDK will automatically request new add based on the set refresh rate. I think that the default is 60s. So, you don`t have to call
requestFreshAd()
at all. Run your app from from Eclipse, go to activity where the adds are, and watch logcat window. Periodically you will see that adds are fetched automatically, based on that refresh rate setting.You can change that refresh rate on http://www.admob.com/my_sites and than clicking 'Manage settings' on an app, and 'App settings'. Also, you can simply set a refresh interval with the
refreshInterval
attribute on the AdView element in your layout XML file.