android - Show and hide AdMob banner with better performance? -


i'm programmming own adroid app. in app i'm using opengl 2d graphics. want implement admmob banner ads make money ( ;) ). banner shown every time player dies in die-screen not while player playing.

the problem is: integrated test ad app began lag , takes few more seconds load die-screen.

to load , hide banner use these 2 methods: (from: the google developer site)

    private void showbanner() {         madview.setvisibility(view.visible);         madview.loadad(adrequest);     }     private void hidebanner() {         madview.setvisibility(view.gone);     } 

my question is: know if can load banner once @ start with:

madview.loadad(adrequest)

and show , hide banner with:

    private void showbanner() {         madview.setvisibility(view.visible);     }     private void hidebanner() {         madview.setvisibility(view.gone);     } 

???????

or against implementation guidance?

ps: method faster because doesn't has load new ad every time player dies.

i use pause/resume adview. so, update code follows:

private void showbanner() {     madview.resume();     madview.setvisibility(view.visible); } private void hidebanner() {     madview.pause();     madview.setvisibility(view.gone); } 

i have being used code in app (available in googleplay) , never received notification doing wrong. so, think there's no problem.

however,

checking google developer website, seems not needed. so, maybe, hide code should ok.. showbanner should updated request new one...

https://developers.google.com/admob/android/games

during gameplay, you'll want hide ad. can done calling hidebanner method:

private void hidebanner() {     adview.setvisibility(view.gone); } 

when game over, call showbanner method again refresh ad , make visible.

private void showbanner() {   adview.setvisibility(view.visible);   adview.loadad(new adrequest.builder()       .addtestdevice(adrequest.device_id_emulator).build()); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -