I got an email from google today that there is a problem with one of my applications
and I need to check Policy center.
This is my Policy centre:
I am using basic code for ad placement.
B4X:
Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
'tablets
height = 90dip
End If
Activity.AddView(AdView1, 0dip, 100%y - height, 100%x, height)
I haven't changed my code for months and it's not clear to me what they are saying: Modified ad code: Resizing Ad Frames?
Did anyone have any similar problems and know what the problem is exactly and how to solve it?
Thank you
I have solved my problem so I have a moral responsibility to share a solution with all of you.
Although it clearly states that the issue is "Modified ad code: Resizing Ad Frames" this is not the case.
The problem was that in some cases I inadvertently partially or completely cover banner ad with a popup menu/dialog.
When I wanted to show the popup dialog I had to set ad.visible=false first.
While it may seem logical now if you try to google the problem, you will find a lot of confused developers who are also not clear about what they did wrong, although they do not resize the ad.
Hope to save someone a few days of life. ?
Thansk @danijel you just saved me a lot of hard work! I just got this warning last night and will be trying to fix it this evening after work (and kids and wife are a sleep).
I think I might be okay. I asked them to review the issue and they came back saying they couldn't find anything breaking policies. Don't know why they stopped ads showing then, luckily it was only for about 10 hours, so no big loss.
i also got this warning few days ago but i really see that the ad is not showing full size even though i use the same code as you posted.
B4X:
Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
'tablets
height = 90dip
End If
Activity.AddView(AdView1, 0dip, 0dip, 100%x, height)
as you can see the banner is not showing full size. it happens on my Galaxy S8. what could be the reason?
if i check the height like this:
If you want to use smart banner, then this code should work:
B4X:
BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
Dim AdMobHeight As Int
Dim ScreenHeightScaled As Float
ScreenHeightScaled = GetDeviceLayoutValues.Height / GetDeviceLayoutValues.Scale
' Ad height 32dip: device screen height <= 400
' Ad height 50dip: 400 < device screen height <= 720
' Ad height 90dip: device screen height > 720
If ScreenHeightScaled <= 400 Then
AdMobHeight = 32dip
Else if ScreenHeightScaled > 400 And ScreenHeightScaled <= 720 Then
AdMobHeight = 50dip
Else if ScreenHeightScaled > 720 Then
AdMobHeight = 90dip
End If
Activity.AddView(BannerAd, 0dip, 100%y - AdMobHeight, 100%x, AdMobHeight)
I have used this code for years without any problem.
Source of your problem is described here:
I can confirm that the original Smart Size Banner code as listed in Post #1 will now be flagged by Admob as being against policy.
Changing to the code in Post #13, then resubmitting in Admob (they do not appear to re-check unless you tell them to), will solve the problem.
Be aware that this code does give noticeably larger size ads on high resolution, small screen devices.