Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

admob positioning problem
Started by sparrowdrunken Aug 15 2013 07:17 AM

* * * * * 5 votes
68 replies to this topic
admob problem positioning zoomeven android
[TOPIC CONTROLS]
Page 2 of 3 1 2 3
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

@ubj3d.android

 

Please take a look at this Android smart banner size: https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners

 

I think 90 comes from 800x90 (Android tablets in Portrait)

 

and 50 comes from 320x50 (iPhone, Windows Phone 8, and most Android phones in Portrait)

 

hmm... so why is there "(display.contentWidth / 320 * 90)" ???



[TOPIC: post.html]
#27

juan.csdc

[GLOBAL: userInfoPane.html]
juan.csdc
  • Enthusiast

  • 69 posts
  • Corona SDK

Thanks Joe, that is correct, the banner size are the one published by Admob.

 

The calculation of (display.contentWidth / 320 * 90) is because corona when building the banner considers a contentWidth of 320, if your config.lua defines your screen size as that then the admob banner is just 90, but if you use any other configuration, like i'm using, (as described in the ultimate config lua) then you need to escalate the banner properly.



[TOPIC: post.html]
#28

tarun9

[GLOBAL: userInfoPane.html]
tarun9
  • Observer

  • 9 posts
  • Corona SDK

local widthInInches = display.pixelWidth / approximateDpi
local heightInInches = display.pixelHeight / approximateDpi
if widthInInches >=5 or heightInInches >= 5 then
   -- its a tablet
   adX = display.screenOriginX
   adY = display.contentHeight - display.screenOriginY - (display.contentWidth / 320 * 90)
else
   adX = display.screenOriginX
   adY = display.contentHeight - display.screenOriginY - (display.contentWidth / 320 * 50)
end
 

This is the calculation for finding out if the device is a tablet or phone.

 

First, a word of warning.  Properties "androidDisplayWidthInInches" and "androidDisplayHeightInInches" have been known to return the wrong values on some devices.

http://forums.coronalabs.com/topic/39312-tablet-detection/?p=203948



[TOPIC: post.html]
#29

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

@juan.csdc

 

Shouldn't it be "(display.contentWidth / 800 * 90)"  instead of 320?

 

And how do you determine if Android device is a tablet or not? 

 

My Galaxy Tab 3 seems using 320x50 banner while it might be considered as a tablet too.



[TOPIC: post.html]
#30

tarun9

[GLOBAL: userInfoPane.html]
tarun9
  • Observer

  • 9 posts
  • Corona SDK

@juan.csdc

 

Shouldn't it be "(display.contentWidth / 800 * 90)"  instead of 320?

 

And how do you determine if Android device is a tablet or not? 

 

My Galaxy Tab 3 seems using 320x50 banner while it might be considered as a tablet too.

 

Check my reply above.



[TOPIC: post.html]
#31

juan.csdc

[GLOBAL: userInfoPane.html]
juan.csdc
  • Enthusiast

  • 69 posts
  • Corona SDK

Hi guys, here is my code to identify devices and properties

 

fx.device = {
        isSimulator         = system.getInfo("environment") == "simulator",
        model                         = system.getInfo("model"),

        width                          = math.floor((displayWidth/display.contentScaleX) + 0.5),
        height                         = math.floor((displayHeight/display.contentScaleY) + 0.5),

        isApple                 = false,
        isAndroid                = false,
        isGoogle                = false,
        isNook                        = false,
        isKindleFire        = false,

        isTablet                = false,

        platformName        = system.getInfo("platformName"),
        platformVersion = system.getInfo("platformVersion"),
}

if string.sub(fx.device.model, 1, 2) == "iP" then
        fx.device.isApple = true

        -- Are we on a tablet?
        if string.sub(fx.device.model, 1, 4) == "iPad" then
                fx.device.isTablet = true
        end
elseif fx.device.platformName == "Android" or fx.device.isSimulator then
        -- Simulator? There's no way to know if the sim. is android, so let's assume that
        
        fx.device.isAndroid = true

        -- If it is android let's assume it is google
        fx.device.isGoogle = true

        -- All of the Kindles start with "K", although Corona builds before #976 returned
   -- "WFJWI" instead of "KFJWI" (this is now fixed, and our clause handles it regardless)
   if model == "Kindle Fire" or model == "WFJWI" or string.sub(fx.device.model, 1, 2) == "KF" then
      fx.device.isKindleFire = true
      fx.device.isGoogle = false  --revert Google Play to false
   end
 
   -- Are we on a Nook?
   if string.sub(fx.device.model, 1 ,4) == "Nook" or string.sub(fx.device.model, 1, 4) == "BNRV" then
      fx.device.isNook = true
      fx.device.isGoogle = false  --revert Google Play to false
   end

   -- Are we on a tablet?
   if system.getInfo("androidDisplayWidthInInches") then
                if(system.getInfo("androidDisplayWidthInInches") > 5 or system.getInfo("androidDisplayHeightInInches" ) > 5) then
                        fx.device.isTablet = true
                end
        end
else
        print("Unknown device")
end

if (display.pixelHeight/display.pixelWidth) > 1.5 then
        fx.device.isTall = true
end

As tarun9 said, I used the 5 inches as a trigger



[TOPIC: post.html]
#32

tarun9

[GLOBAL: userInfoPane.html]
tarun9
  • Observer

  • 9 posts
  • Corona SDK

@juan.csdc

 

You should use the below code to get the width/height in inches.

 

local widthInInches = display.pixelWidth / approximateDpi
local heightInInches = display.pixelHeight / approximateDpi
if widthInInches >=5 or heightInInches >= 5 then
-- its a tablet

end



[TOPIC: post.html]
#33

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

Even I use the following code to see if a device is a tablet

local widthInInches = display.pixelWidth / approximateDpi
local heightInInches = display.pixelHeight / approximateDpi
if widthInInches >=5 or heightInInches >= 5 then
    -- its a tablet
end

My Galaxy Tab returns

 

widthInInches  =     3.7558685446009    

heightInInches =     6.0093896713615

 

So it is categorized as a tablet. 

 

However, the height of the admob Ad shown in the device is actually 50, not 90.

 

It seems there is no correct way to determine if a device is a tablet that uses taller admob ads?



[TOPIC: post.html]
#34

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

This is just plain crazy.

I struggle with this for a few days and there is no solution.

 

HOW TO POSITION THE ADMOB BANNER AT THE BOTTOM IN LANDSCAPE ?

 

Here is my config.lua:

 

local aspectRatio = display.pixelHeight / display.pixelWidth

-- background size: width = 640*1.125=720, height = 960*1,1875=1140
application = {
   content = {
 width = aspectRatio > 1.5 and 640 or math.ceil( 960 / aspectRatio ),
      height = aspectRatio < 1.5 and 960 or math.ceil( 640 * aspectRatio ),
      scale = "letterBox",
      fps = 60,
   },
   
}

 

I guess the formula should be like this:

 

adY = display.contentHeight - display.screenOriginY - bannerHeight

 

For all devices I tested I got display.screenOriginY=0 so the formula is simple:

 

adY = display.contentHeight  - bannerHeight

 

The milion dollar question is how to determine the bannerHeight ???

 

I have tested on 4 devices and found that the banner height is different on all of them.

Here is the complete table:

 

bannerHeight.jpg

I have tried many, many variations to get the formula which would give me the bannerHeight from contentWidth,contentHeight,pixelWidth,pixelHeight,ascpectRatio but with no success.

 

Is there really noone using admob at bottom in landscape?

 

HELP PLEASE!



[TOPIC: post.html]
#35

juan.csdc

[GLOBAL: userInfoPane.html]
juan.csdc
  • Enthusiast

  • 69 posts
  • Corona SDK

I would vote for Corona to include an API call to get the banner height, if not this is impossible. Also for iAds, even if you set y=display.contentHeight, and the banner is beautifully shown at the bottom of the screen, to render everything else I need to know the ad height.

 

+1 for this API



[TOPIC: post.html]
#36

juan.csdc

[GLOBAL: userInfoPane.html]
juan.csdc
  • Enthusiast

  • 69 posts
  • Corona SDK

Guys, I just created a feature request for this, please support it so that Corona would implement it!

 

Here is the link to the idea:

 

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5245292-implement-banner-height-as-api-call-for-the-ads-mo

 

I gave it myself 3 votes



[TOPIC: post.html]
#37

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

I would vote for Corona to include an API call to get the banner height, if not this is impossible. Also for iAds, even if you set y=display.contentHeight, and the banner is beautifully shown at the bottom of the screen, to render everything else I need to know the ad height.

 

+1 for this API

I thought you find a solution (although it isn't working for me) ?



[TOPIC: post.html]
#38

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

This is getting even more weird.

 

I continued to test admob, now in portrait on the same devices and config.lua as above.

 

Here are the results of the banner heights:

 

Xperia = 100

LG = 100

Transformer = 72

Galaxy Tab = 96



[TOPIC: post.html]
#39

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Here is the updated table with 2 more phones added (1 is same as LG so actually there is one new):

 

bannerHeight.jpg

 

 

If there is a mathematical genius out there to find the formula for banner height, please help.



[TOPIC: post.html]
#40

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

@ubj3d.android  I don't have many Android devices to test with. It's really great to see your table. Could you add "display.screenOriginX" to your table?

 

Your question:

 

HOW TO POSITION THE ADMOB BANNER AT THE BOTTOM IN LANDSCAPE ?

 

Exactly my question too (Portrait as well).

 

Right now my solution is "NOT" to place any ad in Android devices because I don't know how to place admob at the exact bottom. I am waiting for Corona response, but it seems they are very quiet on this issue and I don't know why.

 

For me, there are many issues I don't have exact answers for:

 

(1) How to determine exactly if a device is a tablet where taller ads are placed? juan.csdc created a feature request for this,

 

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5245292-implement-banner-height-as-api-call-for-the-ads-mo

 

I voted +3 too.

 

(2) To calculate the admob ad height (portrait), I use this formula (my configu.lua uses 320x480, letterbox)

if (tablet) then  -- as stated in (1), it's a problem to determine for this tablet variable
    ret = (display.contentWidth-display.screenOriginX) / 800 * 90   -- not sure 800 or 320
else
    ret = (display.contentWidth-display.screenOriginX) / 320 * 50
end

a. should I use 800 or 320 in line 2? According to the smart banner document, it should be 800x90, but according to juan.csdc, he uses 320. And I don't really have an Android tablet to test with.

 
b. When I test Sony Xperia, the admob ads are placed at the exact bottom perfectly. However for my Galaxy Tab, there are 3 pixels space between the ad and the bottom of the screen. I can see my background through this space, which is bad. I am not sure if it's by design due to screen scaling or there is still something wrong with this formula.
 
c. Although you haven't provided display.screenOriginX in your table, the ad heights you provided are far from the values that would be generated by this formula. So it's now getting more confusing. (How do you calculate the ad heights in your table? By experiments, moving one pixel at a time?)
 
d. There is one more confusing thing. In order to place admob at the exact bottom for "Apple" devices, I use a different way to calculate the y value. Instead of 
 
adY = display.contentHeight - display.screenOriginY - bannerHeight
 
I have to use
 
adY = display.contentHeight - display.screenOriginY - display.screenOriginY
 
Sounds very strange? Yes, very strange, but this works for iPad 4, iPad air, iPhone 4S/5/5S. I don't know why either.
 
 
It is driving me crazy too. 


[TOPIC: post.html]
#41

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

With the ultimate config.lua, display.screenOriginX and display.screenOriginY are 0.

 

So the formula is very simple:

 

y = display.contentHeight  -  bannerHeight

 

To get the needed bannerHeight I used my parameters which I can change in "cloud" (my server), so no need to make a new APK every time, I just changed a parameter in my database on the server.

 

I moved the banner, pixel by pixel until perfect fit.

 

Your formula is not right, as you saw the Galaxy Tab has a "hole" if you put 50.

My contentWidth is twice as yours, hence 100 (96 for Galaxy Tab).

 

 

I have read and tried every solution suggested, none works.

 

Hopefully Corona stuff will help with this as this is really an ESSENTIAL feature - placing the banner at the bottom.

 

Will test with 2 more devices (a phone and a tablet) and add the results to the table.

 

Regards,

Damir.



[TOPIC: post.html]
#42

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

Hi Damir,

 

Sure, I don't like the formula either if it just fits my config.lua and doesn't work for your case. And the 3-pixels hole is also a concern.

 

And if you have Apple devices, give it a try too, you should be more surprised about the inconsistency.

 

I also hope Corona can address this issue. I have been asking them here and there in different forum threads about the inconsistencies when placing ads (iad/admob) at the exact bottom in different iOS/Android devices, but no responses.

 

Consider iad/admob + iOS/Android + different config.lua, there are tons of test cases, and I haven't found the consistency. Placing ad should be a high priority for Corona because it's one of the main sources for developers to make some money. I really hope Corona can address this high priority + fundamental issue.



[TOPIC: post.html]
#43

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

Hi Damir,

 

Did you misplace wrong column names for contentHeight & contentWidth in your table?



[TOPIC: post.html]
#44

tarun9

[GLOBAL: userInfoPane.html]
tarun9
  • Observer

  • 9 posts
  • Corona SDK

Corona staff should reply to this thread with detailed analysis and workaround. 



[TOPIC: post.html]
#45

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Hi Damir,

 

Did you misplace wrong column names for contentHeight & contentWidth in your table?

 

Hi Joe,

 

no, that is because the game is in landscape.

 

 

There is one more thing not implemented in Corona-AdMob - "normal" banners.

 

In my game "Ultimate BlackJack 3D" written in Java I use normal banner, it perfectly fits my screen design in landscape (bottom-right).

 

We made a similar, improved game in Corona "Ultimate BlackJack Reloaded" but unfortunately can't have the same design due to the above problem + the smartbanner positioning problem.

 

I have to add, we have tried MANY MANY different ad networks (in Corona and native Java) and none can beat admob.

They all make great promises but in the end none of them could beat admob.

 

Getting FULL support for AdMob ads should be a high-priority for Corona, but I am afraid we will not get it.

 

 

Regards,
Damir.



[TOPIC: post.html]
#46

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,062 posts
  • Enterprise

Engineering is looking into the problem.

 

Rob



[TOPIC: post.html]
#47

tarun9

[GLOBAL: userInfoPane.html]
tarun9
  • Observer

  • 9 posts
  • Corona SDK

I hope we get some solution quite soon... We all depends on Admob as a devloper.. 



[TOPIC: post.html]
#48

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Engineering is looking into the problem.

 

Rob

Great to hear. Hopefully we have a solution soon.

 

Would be beautiful if we get "normal banner" support.

Smartbanners in landscape are only text-based and have lower CTR.



[TOPIC: post.html]
#49

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,062 posts
  • Enterprise

How soon would be oh say..... now?

 

Simply position the Y at something really large like 10000 and it should auto-position to the bottom.  iAds does the same thing.  Since this is done through a plugin, it should be live ready to go.

 

 

Rob



[TOPIC: post.html]
#50

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

Simply position the Y at something really large like 10000 and it should auto-position to the bottom.  iAds does the same thing.  Since this is done through a plugin, it should be live ready to go.

 

From my testing, admob does not do the same. It will go under the bottom of the screen for Android devices. Besides, I have been saying there is inconsistency for admob between Android & iOS devices (& inconsistency between iAd & admob). With the combinations of these 4 variables, I am totally lost when trying to put the ad at the bottom.

 

Unless there is some new update for the plugin for the last 10 days because I haven't (or say gave up) tested them again since 10 days ago.




[topic_controls]
Page 2 of 3 1 2 3
 
[/topic_controls]