Android Question Adaptive Banners

Lucas Eduardo

Active Member
Licensed User
From code posted by Erel on this thread https://www.b4x.com/android/forum/threads/admob-adaptive-banners.111525/
1:
Code:
B4X:
Sub GetAdaptiveAdSize As AdSize
   Dim ctxt As JavaObject
   ctxt.InitializeContext
   Dim AdSize As JavaObject
   Dim width As Int = 100%x / GetDeviceLayoutValues.Scale
   Dim res As AdSize
   res.Native = AdSize.InitializeStatic("com.google.android.gms.ads.AdSize").RunMethod("getCurrentOrientationAnchoredAdaptiveBannerAdSize", Array(ctxt, width))
   Dim jo As JavaObject = res.Native
   res.Width = jo.RunMethod("getWidthInPixels", Array(ctxt))
   res.Height = jo.RunMethod("getHeightInPixels", Array(ctxt))
   Return res
End Sub
2: Add to Process_Globals
Code:
B4X:
Type AdSize (Native As Object, Width As Int, Height As Int)
3. Usage:
Code:
B4X:
Dim size As AdSize = GetAdaptiveAdSize
adview1.Initialize2("ad", "ca-app-pub-126753333333/948333333", size.Native)
Activity.AddView(adview1, 0, 0,  size.Width, size.Height)

I'm getting this error
java.lang.RuntimeException: Method: getCurrentOrientationAnchoredAdaptiveBannerAdSize not found in: com.google.android.gms.ads.AdSize

What am i missing?
 

DonManfred

Expert
Licensed User
What am i missing?
probably you are using an "old" artifact.

18.3.0 2019‑11‑05
^^^^ Version where getCurrentOrientationAnchoredAdaptiveBannerAdSize is added to the artifact.

Start B4ASDKManager and download all recommended items.

Try again.
 
Upvote 0
Top