AdMob: ad on top & bottom of the screen

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

AdMob: ad on top & bottom of the screen

Postby tonyp7 » Tue Nov 13, 2012 6:40 am

Hello,

Thanks to the author of http://code.google.com/p/libgdx/wiki/AdMobInLibgdx, I could setup quickly admob with my app.

However, it says the following about showing/hiding ads:
This example will show you how to turn the AdMob View's visibility on and off from within your libgdx app. Note that this is probably not the best way to control AdMob. If your ad View is invisible, but still fetching ads in the background, then you're wasting ad impressions, and that will negatively impact your ad revenue. I'm not going to talk about the best way to control the AdMob view - that varies from application to application. Also, there are things you can do on the website, and things you can do in your app. So look through the AdMob documentation for more information on that.


Hmm... OK... So what's the best practice?

I need to have an AdView showing on top during the menu, and at the bottom while playing.

So I have created 2 AdView and I can show/hide the right one. However this doesn't seem to be best practice.

What should I do? Remove/Readd the view from the layout? How is this thing working?

Thanks!
tonyp7
 
Posts: 336
Joined: Fri Feb 17, 2012 1:02 pm

Re: AdMob: ad on top & bottom of the screen

Postby Silverwolf » Tue Nov 13, 2012 7:45 am

I not tried it yet, but I had found this

http://unscrambleronline.com/wp/2012/ho ... t-runtime/
Cool skys and grass and other digital painting try http://www.artistcanvas.org/
Silverwolf
 
Posts: 346
Joined: Sun May 27, 2012 7:36 am

Re: AdMob: ad on top & bottom of the screen

Postby tonyp7 » Tue Nov 13, 2012 9:05 am

Thanks Silverwolf. This code is based on hiding views as well though.

Oh well; I can't find anything else; I might just go for this!
tonyp7
 
Posts: 336
Joined: Fri Feb 17, 2012 1:02 pm

Re: AdMob: ad on top & bottom of the screen

Postby Magnesus » Tue Nov 13, 2012 9:42 am

I use one adview and move it around (in the handler):

Code: Select all
this.runOnUiThread(new Runnable() {
               @Override
               public void run() {
                  RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT,
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
                  adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); // change it to bottom to move to bottom
                  adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
                  adView.setLayoutParams(adParams);
               }
            });
Magnesus
 
Posts: 1620
Joined: Sun Sep 25, 2011 3:50 pm

Re: AdMob: ad on top & bottom of the screen

Postby tonyp7 » Tue Nov 13, 2012 9:52 am

Thanks Magnesus. This has been puzzling me "addRule" would mean you add rules on top of eachothers. But in fact; you're basically saying they replace each others?
tonyp7
 
Posts: 336
Joined: Fri Feb 17, 2012 1:02 pm

Re: AdMob: ad on top & bottom of the screen

Postby Magnesus » Tue Nov 13, 2012 10:44 am

No, you are adding rules to the adParams object (so the adview will be both on top because of ALIGN_PARENT_TOP and centered horizontally because of the next rule). And then you replace all params in adview with that new object by setLayoutParams. :)
Magnesus
 
Posts: 1620
Joined: Sun Sep 25, 2011 3:50 pm

Re: AdMob: ad on top & bottom of the screen

Postby tonyp7 » Wed Nov 14, 2012 3:32 am

Perfect!

That's exactly what I needed! Thanks Magnesus!
tonyp7
 
Posts: 336
Joined: Fri Feb 17, 2012 1:02 pm

Re: AdMob: ad on top & bottom of the screen

Postby wordunscramblerco » Sat Aug 04, 2018 9:29 am

I'm also facing the same issue with my site: https://wordunscrambler.co/
wordunscramblerco
 
Posts: 1
Joined: Sat Aug 04, 2018 9:28 am


Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest