Android Question .

worm

Member
Licensed User
Longtime User
Hello, I use this code:
B4X:
Sub Globals
   Dim pnlAD As Panel
   Dim AdBar As AdView
   Dim AD_SIZE As Object
   Dim adWidth As Int
   Dim adHeight As Int
End Sub

Sub AdBarInit
   ' set the AD Bar, choose the right size
   If pnlAD.Width < 468dip Then
       ' normal
      AD_SIZE = AdBar.SIZE_BANNER
      adWidth = 320dip
      adHeight = 50dip
   Else If pnlAD.Width < 728dip Then
      ' large
       AD_SIZE = AdBar.SIZE_IAB_BANNER
      adWidth = 468dip
      adHeight = 60dip
   Else
      ' tablet
       AD_SIZE = AdBar.SIZE_IAB_LEADERBOARD
      adWidth = 728dip
      adHeight = 90dip
   End If
   ' add the AD bar on the panel
   AdBar.Initialize2("Ad", "xxxxxxxxxxxxxxxx", AD_SIZE)
   pnlAD.AddView(AdBar, 50%x-(adWidth/2), 0, adWidth, adHeight)
   'AdBar.LoadAd
   Log("AD initialized")
End Sub

pnlAD is a pannel added to the activity, I change the size with the Designer Code.
 
Upvote 0

worm

Member
Licensed User
Longtime User
Yes :) you have to set width and height of the panel in the designer.

See the attached project.

I set the width and height for each Layout variant.
 

Attachments

  • ADTest.zip
    7.4 KB · Views: 267
  • shot.png
    shot.png
    16.7 KB · Views: 288
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Be very careful when you choose large Admob units. Google's TOS specifically states that phones should use 320x50 only and not the bigger or wider units. Units 300x250, 468x60 and 728x90 are to be used on tablets only. I asked Google support and they confirmed it.

And you can't differentiate tablets and phones with resolution alone. A common tablet resolution is 1280x800 but Samsung Galaxy Note which is a 5.3" phone also uses that. You should use 320x50 on Galaxy Note while any of the other units on devices that have 7" or bigger display, which is how tablets are normally defined.

So I would say, consider the physical size of the device as well, when selecting the right ad unit. Sure, a 320x50 looks bad on Galaxy Note, Galaxy Nexus and all the top-end 1280x720 phones but unfortunately if you use a bigger unit, Google might suspend the account.
 
Upvote 0

worm

Member
Licensed User
Longtime User
Be very careful when you choose large Admob units. Google's TOS specifically states that phones should use 320x50 only and not the bigger or wider units. Units 300x250, 468x60 and 728x90 are to be used on tablets only. I asked Google support and they confirmed it.

And you can't differentiate tablets and phones with resolution alone. A common tablet resolution is 1280x800 but Samsung Galaxy Note which is a 5.3" phone also uses that. You should use 320x50 on Galaxy Note while any of the other units on devices that have 7" or bigger display, which is how tablets are normally defined.

So I would say, consider the physical size of the device as well, when selecting the right ad unit. Sure, a 320x50 looks bad on Galaxy Note, Galaxy Nexus and all the top-end 1280x720 phones but unfortunately if you use a bigger unit, Google might suspend the account.

Thank you for this information!
Attached the corrected version to detect physical size of the screen.
The panel is adjusted by code (and no more by Designer Script)
:sign0142:
 

Attachments

  • ADTestPhysical.zip
    7.4 KB · Views: 286
Upvote 0
Top