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);
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.
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.
Thanks for the help.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With