Proper Way to Temporarily Disable Ads?

272 views
Skip to first unread message

Game Makr

unread,
Jan 11, 2015, 9:28:42 AM1/11/15
to google-adm...@googlegroups.com
I was wondering if there is a "right" way to temporarily disable the ads. I am making a game (hence the display name) with both banner and interstitial ads. What I'm trying to achieve is a steady ~60 frames per second with virtually no stutter or hiccups.

To disable the ads and their associated requests, I'm currently doing this:

    adView.setVisibility(View.INVISIBLE);
    adView.setEnabled(false);
    adView.pause();

To re-enable them, I'm doing:

    adView.setVisibility(View.VISIBLE);
    adView.setEnabled(true);
    adView.resume();

Is this correct? Am I missing anything? Do I have extraneous code?

Also, how would I know whether or not a banner ad is currently displaying an ad? I've noticed that after disabling the ads then re-enabling after ~3 min, the ad is no longer visible. Is it necessary to reload an ad instead of waiting for the refresh to kick in?

Thank you!! I'm sorry for inundating you guys with all of these questions simultaneously!

Game Makr

unread,
Jan 12, 2015, 5:31:37 PM1/12/15
to google-adm...@googlegroups.com
Anyone?

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Jan 12, 2015, 8:06:21 PM1/12/15
to google-adm...@googlegroups.com
Normally when people are placing ads in games, they use interstitials at natural breaks in the action (you mention including interstitials, so you've made a good choice there), and banner ads on menus, pause screens and so forth.  It's generally not recommended to have an AdView up and running while the user is actually playing the game.  Not only will the JS in some ads slow down performance, but your user is much less likely to see and consider clicking on the ad, which is worse for both advertisers and developers.

With banner ads, this normally means the banner lives in a fragment or activity that's created when the user pauses or chooses to bring up a menu, and afterwards is destroyed.  With this architecture you don't have to worry about what the AdView's doing when not displayed because it's no longer around.

-Andrew

Game Makr

unread,
Jan 16, 2015, 9:46:46 PM1/16/15
to google-adm...@googlegroups.com
Thanks for the tips. I've noticed that having an AdView up and running during gameplay has pretty detrimental effects on performance, so I've disabled when appropriate.

So, if I have a single RelativeLayout containing both the AdView and my game's view, do you think it would be sufficient to simply remove the AdView from the Layout when it's not in use? How else would I go about destroying it?

I am not currently using Fragments, unfortunately.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Jan 20, 2015, 1:43:44 PM1/20/15
to google-adm...@googlegroups.com
It's possible to add and remove an AdView from a layout as you would any other view (Button, TextEdit, etc.) using the addView and removeView methods. Just be sure to destroy the old one properly after removing it, and create a new AdView object when you're ready to put one in.

-Andrew
Reply all
Reply to author
Forward
0 new messages