Android Question AdMob - Adaptive Banners

Erel

Administrator
Staff member
Licensed User
Yes.

1:
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
B4X:
Type AdSize (Native As Object, Width As Int, Height As Int)
3. Usage:
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)
 

asales

Well-Known Member
Licensed User
3. Usage:
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)
And this line:
B4X:
adview1.LoadAd
 

joaomoraes83

Member
Licensed User
I installed the recommendations but problem persists.
I am using the ready to use SDK.
Is the adaptive banner only available for V9.5 +?
 

DonManfred

Expert
Licensed User
I installed the recommendations but problem persists.
Which problem? I don´t see you posted it in this thread!?
If you have a problem then i suggest to start a new thread for your Issue, post all relevant code, and the FULL ERROR you got (as TEXT).
 
Top