Sub Activity_Create(FirstTime As Boolean)
Dim AdaptiveSize As Map = GetAdaptiveAdSize
'Add Private BannerAd As AdView in Globals sub
BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111",AdaptiveSize.Get("native"))
Activity.AddView(BannerAd, 0, 0, AdaptiveSize.Get("width"), AdaptiveSize.Get("height"))
BannerAd.LoadAd
End Sub
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 Ad_ReceiveAd
Log("Adview received")
End Sub
Sub Ad_FailedToReceiveAd (ErrorCode As String)
Log("Failed: " & ErrorCode)
End Sub
Sub Ad_AdClosed
Log("Closed")
End Sub
Sub Ad_AdOpened
Log("Opened")
End Sub