#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim AdViewCollapsible As AdView
Type AdSize (Native As Object, Width As Int, Height As Int) 'there is another option using AdsHelper class
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
Activity.Title = "Activity Collapsible Banner"
Dim size As AdSize = GetAdaptiveAdSize
AdViewCollapsible.Initialize2("AdViewCollapsible", "ca-app-pub-3940256099942544/2014213617", size.Native)
Dim jo As JavaObject
jo.InitializeContext
Dim builder As AdRequestBuilder = jo.RunMethod("GetCollapsibleRequest", Array("bottom"))
Activity.AddView(AdViewCollapsible, 0, 100%y - size.Height, size.Width, size.Height)
AdViewCollapsible.LoadAdWithBuilder(builder)
End Sub
Sub Activity_Resume
' Place any code here that needs to run when the activity resumes
AdViewCollapsible.Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
AdViewCollapsible.Pause
End Sub
'Adaptive Banners
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
#If Java
import android.os.Bundle;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
public AdRequest.Builder GetCollapsibleRequest(String placement) {
AdRequest.Builder builder = new AdRequest.Builder();
Bundle extras = new Bundle();
extras.putString("collapsible", placement);
builder.addNetworkExtrasBundle(AdMobAdapter.class, extras);
return builder;
}
#End If