I am developing a game and it is going well. However, I have a problem updating AdMob ads. Every time an ad is updated or draws another aspect of the ad, my frame rate drops and almost makes the game unplayable. Here is what I have to download ads ...
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 an ad on top of SurfaceView was to simply add it to RelativeLayout and add both SurfaceView and AdView . All this works fine and dandy, but every time the ad is updated (user interface or new ad request), it wraps the user interface flow, which in turn slows down the rendering flow.
Is there a way by which I can do all this together well so that all the work done by AdView is done separately from the main thread? I'm not too sure about dynamically updating the current layout from another thread.
Thanks for the help.
Sempergumbee
source share