Is there a way to preload AdMob ads on Android?

痞子三分冷 提交于 2019-12-01 18:49:32
RBK

I have done it by use one adview multiple time and in multiple activity

It just load once, and you can use it where ever you want,

It will refresh on its given refresh rate.

demo is given here

you may need some modification but actual idea is implemented.

So your problem is the empty banner space? if is that so, an alternative solution to avoid empty banner space as below;

  • put AdMob banner inside FrameLayout together with placeholder view (e.g. image etc)
  • implement "public void onReceiveAd(Ad ad)" to swap views as u know the banner arrived.

on the other hand,
(my humble opinion) having banner inside Dialog, by nature, is not optimum place.
I would suggest to place the banner on main Activity views only, this is where user spends most of their time.

First in another persistent context, you create AdView of admob and load ad with AdRequest.

And then, add the AdView in 'onCreateView' of DialogFragment. Make sure the AdView is removed from previous parent view.

if (adView.getParent() != null) {
    ((ViewGroup) adView.getParent()).removeView(adView);
}

// Add the banner ad to the ad view.
adCardView.addView(adView);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!