有没有办法在 Android 上预加载 AdMob 广告?
我的应用程序中的“对话框”(我创建的一个看起来像这样的视图,因为广告不适合正常的对话框)中有一个 AdMob 广告。通常,广告加载大约需要 4 或 5 秒的时间,并且由于它位于“对话框”中,因此用户很可能会在广告加载之前单击按钮(关闭对话框)。
有没有办法可以预加载广告,以便它们在创建包含的视图后立即显示?
I have a AdMob ad in a "dialog" (a View I created to look like one, because ads will not fit in a normal Dialog) in my app. Usually it takes about 4 or 5 seconds before the ad loads, and since it's in a "dialog," the user will most likely click a button (closing the dialog) before the ad loads.
Is there a way I can preload the ads so that they will show as soon as their containing View is created?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经通过多次使用一个广告视图并在多个活动中完成了它
,它只加载一次,您可以在任何您想要的地方使用它,
它将以其给定的刷新率刷新。
这里给出了演示,
您可能需要一些修改,但实际的想法已经实现。
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.
首先,在另一个持久上下文中,创建 admob 的 AdView 并使用 AdRequest 加载广告。
然后,在 DialogFragment 的“onCreateView”中添加 AdView。确保 AdView 已从之前的父视图中删除。
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.
那么您的问题是横幅空间空白?
如果是这样,请使用避免空白横幅空间的替代解决方案,如下所示;
另一方面,
(我的拙见)在 Dialog 中放置横幅本质上并不是最佳位置。
我建议仅将横幅放置在主活动视图上,这是用户花费大部分时间的地方。
So your problem is the empty banner space?
if is that so, an alternative solution to avoid empty banner space as below;
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.