Android Question Banner in the footer is cutting (horizontal and vertical)

Ederson Kerber

Member
Licensed User
Hi,

I started using FirebaseAdMob2 - Google Mobile Ads SDK 20+ as instructed: https://www.b4x.com/android/forum/threads/firebaseadmob2-google-mobile-ads-sdk-v20.129609/#content and my banners cut (horizontal and vertical).

B4X:
Sub GetAdaptiveAdSize As Map
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim AdSize As JavaObject
    Dim width As Int = 100%x / GetDeviceLayoutValues.Scale
    Dim Native As JavaObject = AdSize.InitializeStatic("com.google.android.gms.ads.AdSize").RunMethod("getCurrentOrientationAnchoredAdaptiveBannerAdSize", Array(ctxt, width))
    Return CreateMap("native": Native, "width": Native.RunMethod("getWidthInPixels", Array(ctxt)), _
        "height": Native.RunMethod("getHeightInPixels", Array(ctxt)))
End Sub

Sub position_banner
    Dim AdaptiveSize As Map = GetAdaptiveAdSize
    Dim height As Int = AdaptiveSize.Get("height")
    Activity.AddView(BannerAd, 0, (100%y - height),  AdaptiveSize.Get("width"), height)
    BannerAd.LoadAd
    BannerAd.BringToFront
End Sub

Video below:

B4A Version 10.90

Thanks for any suggestions.
 

Pendrush

Well-Known Member
Licensed User
Longtime User
B4X:
Activity.AddView(BannerAd, 0, (100%y - height),  AdaptiveSize.Get("width"), height)
change to
B4X:
Activity.AddView(BannerAd, 0, (100%y - height),  100%x, height)
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Leaving it this way, won't I have problems with Admob policies?
Yes, you will.
Google can claim this issue: "Modified ad code: Resizing Ad Frames".

Strange behaviour is this with your banner.
Do you use this code in the ad unit test: ca-app-pub-3940256099942544/6300978111 ?
I tried and works fine here.

Please, export your project as zip and put it here to test.
 
Upvote 0

Ederson Kerber

Member
Licensed User
Hi,

I did some more tests to get more data. See below:

1. I ran the same project (no changes) on four different devices and none of them had a problem showing the FIRST AD.
2. I left the apps open for a while to force the banner ads/advertiser change and after a few minutes on one of the devices, I got an ad that was cut off again. Image below:

Sansung J7 Cut.jpg


3. I noticed that in most cases there is no problem, the banner doesn't cut. But in some cases, depending on the ad/advertiser it will be cut off.
4. Ads with the test block: ca-app-pub-3940256099942544/630097811 I didn't see a problem. Only using valid ad units.
5. I attach a small project test for evaluation and any help.
6. Remember to change the line below to a valid ad unit on Activity_Create:
B4X:
BannerAd.Initialize2("BannerAd", "ca-app-pub-****************/*********", AdaptiveSize.Get("native"))
7. Remember to change the line below with your Admob account data in the manifest:
B4X:
AddReplacement($ADMOB_APP_ID$, ca-app-pub-***************~*********)

Thanks again for the help!
 

Attachments

  • test.zip
    335.5 KB · Views: 229
Upvote 0

asales

Expert
Licensed User
Longtime User
Works fine here.

Real ads banners:
2.jpg 3.jpg 4.jpg

What device model causes this issue in the first ad?
I tested in a Moto G4 with Android 7.
I waited for a banner update and still works.

Did you try to create and use another real ad unit?

I don't know why your test ad banner is show like this:
View attachment 114917

my test ad banners always show like this:
1a.jpg


5a.jpg
 
Upvote 0

Ederson Kerber

Member
Licensed User
I had two devices that cut the banner:
- Samsung J7 Android 8.1;
- Xiaomi Redmi Note 9s Android 11

I created another ad block, but the same error occurred.

But most of the time on these same devices the banner does not cut. Not all banner ads get cut, just a few. It depends on the ad/advertiser. I couldn't identify the reason for this happening with just a few ads.
 
Upvote 0
Top