AdMob广告刷新会破坏帧频

AdMob广告刷新会破坏帧频

本文介绍了Android,AdMob:AdMob广告刷新会破坏帧频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款游戏,并且进展顺利。不过,我确实在刷新AdMob广告方面存在一些问题。每次刷新广告或绘制广告的不同方面时,我的帧频都直线下降,几乎使游戏无法玩。这是我要加载的广告的内容。

I am developing a game and it's coming along quite nicely. I do have a bit of a problem about the AdMob ad refreshing though. Every time the ad is refreshed or it draws a different aspect of the ad, my frame rate plummets and almost makes the game unplayable. Here is what I have for the loading of the ad...

    ad = new AdView(this, AdSize.BANNER, "...");

    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice("...");
    adRequest.addTestDevice("...");

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    ad.setLayoutParams(lp);

    RelativeLayout layout = new RelativeLayout(this);
    layout.addView(renderView);
    layout.addView(ad);
    ad.loadAd(new AdRequest());

    setContentView(layout);

我在 SurfaceView 只是将其添加到 RelativeLayout 并同时添加 SurfaceView AdView 。所有这些都很好用,但每次广告刷新(UI或新的广告请求)时,它都会陷入UI线程的停顿,这反过来又减慢了我的渲染线程的速度。

My solution for rendering the ad on top of the SurfaceView was to just add it to a RelativeLayout and add both the SurfaceView and AdView to it. This all works fine and dandy, but every time the ad refreshes (UI or new Ad request), it bogs down the UI thread, which in turn slows down my render thread.

是否可以将所有这些工作很好地结合在一起,以使AdView完成的所有工作与主线程分开完成?我不太确定要从另一个线程动态更新当前布局。

Is there a way that I can make all of this work together nicely to have all work done by the AdView done separately from the main thread? I am not too sure about dynamically updating the current layout from another thread.

感谢帮助。

推荐答案

我也遇到了这个问题。我发现这是由Google广告更改时产生动画效果而不是完全没有动画效果的静态Admob标语广告引起的。 admob应用程序设置中有一个用于控制是否使用Google广告的设置...请尝试将其关闭以查看是否有效果。

I had this problem too. I found it was caused by Google ads which animate when they change, rather than static Admob banner ads which don't animate at all. There's a setting in your admob app settings for controlling whether Google ads are used... try turning it off to see if it makes a difference.

这篇关于Android,AdMob:AdMob广告刷新会破坏帧频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:13