Android Question AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
Public Sub GetInlineAdaptiveBannerAdSize As JavaObject
    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("getCurrentOrientationInlineAdaptiveBannerAdSize", Array(ctxt, width))
   Return AdSize
End Sub
 
Upvote 0

nyinyi

Member
Something like:
B4X:
Public Sub GetInlineAdaptiveBannerAdSize As JavaObject
    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("getCurrentOrientationInlineAdaptiveBannerAdSize", Array(ctxt, width))
   Return AdSize
End Sub
Do I need to specify the height of Ad Size?
 
Upvote 0

nyinyi

Member
Something like:
B4X:
Public Sub GetInlineAdaptiveBannerAdSize As JavaObject
    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("getCurrentOrientationInlineAdaptiveBannerAdSize", Array(ctxt, width))
   Return AdSize
End Sub
How to code
Returns whether this AdSize is auto-height.
 
Upvote 0

nyinyi

Member
If so, what could be the problem.Have something error if use it like this?

B4X:
Sub Globals
Private banner As AdView
Private content1,content2 As Label
Private sv As ScrollView
End Sub

Sub Activity_Create(FirstTime As Boolean)

sv.Initialize(1000dip)
Activity.AddView(sv,0,0,100%x,100%y)

content1.Initialize("")
content1.Text="Content1"
sv.panel.addview(content1,0,0,sv.width,100dip)

 banner.Initialize2("banner", "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx",GetInlineAdaptiveBannerAdSize)
sv.panel.addview(banner,0,(content1.Top+content1.Height),sv.width,0)

content2.Initialize("")
content2.Text="Content1"
sv.panel.addview(content2,0,(banner.Top+banner.Height),sv.width,100dip)

sv.panel.height=content2.top+content2.height

End Sub

Sub banner_ReceiveAd
banner.SetLayout((sv.width/2)-150dip,content1.top+content1.height,300dip,250dip)
content2.SetLayout(0,banner.top+banner.height,sv.width,100dip)
sv.panel.height=content2.top+content2.height

End Sub

Public Sub GetInlineAdaptiveBannerAdSize As JavaObject
    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("getCurrentOrientationInlineAdaptiveBannerAdSize", Array(ctxt, width))
   Return AdSize
End Sub
 
Last edited:
Upvote 0

asales

Expert
Licensed User
Longtime User
Do I need to specify the height of Ad Size?
Check this code:
And this example:
 
Upvote 0
Top