AdMob API and keywords

2019-06-24 19:04发布

问题:

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.

回答1:

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.