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)
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).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.