Android Programming Press on the image to return to the main documentation page.

FirebaseAdMob

List of types:

AdRequestBuilder
AdView
ConsentManager
InterstitialAd
NativeExpressAd
RewardedVideoAd

AdRequestBuilder


Events:

None

Members:


  AddTestDevice (DeviceId As String) As AdRequestBuilder

  Initialize As AdRequestBuilder

  IsInitialized As Boolean

  NonPersonalizedAds As AdRequestBuilder

Members description:

AddTestDevice (DeviceId As String) As AdRequestBuilder
Add a test device. You can see the device id in the unfiltered logs.
Initialize As AdRequestBuilder
IsInitialized As Boolean
NonPersonalizedAds As AdRequestBuilder
Request non-personalized ads.

AdView


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Permissions:

android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE

Events:

ReceiveAd
FailedToReceiveAd (ErrorCode As String)
AdScreenDismissed
PresentScreen

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  Enabled As Boolean

  Height As Int

  Initialize (EventName As String, PublisherId As String)

  Initialize2 (EventName As String, AdUnitId As String, Size As Object)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  LoadAd

  LoadAdWithBuilder (Builder As AdRequestBuilder)

  LoadAdWithTestDevice (TestDevice As String)

  Padding() As Int

  Parent As Object [read only]

  Pause

  RemoveView

  RequestFocus As Boolean

  Resume

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  SIZE_BANNER As Object

  SIZE_IAB_BANNER As Object

  SIZE_IAB_LEADERBOARD As Object

  SIZE_IAB_MRECT As Object

  SIZE_SMART_BANNER As Object

  Tag As Object

  Top As Int

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
Enabled As Boolean
Height As Int
Initialize (EventName As String, PublisherId As String)
Initializes the AdView using the default 320dip x 50dip size.
EventName - Name of Subs that will handle the events.
PublisherId - The publisher id you received from AdMob.
Initialize2 (EventName As String, AdUnitId As String, Size As Object)
Initializes the AdView.
EventName - Name of Subs that will handle the events.
AdUnitId - The Ad unit id received from AdMob.
Size - One of the SIZE constants.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
LoadAd
Sends a request to AdMob, requesting an ad.
LoadAdWithBuilder (Builder As AdRequestBuilder)
Requests an ad configured with AdRequestBuilder.
LoadAdWithTestDevice (TestDevice As String)
Requests an ad.
TestDevice - The test device id. You can see the id in the unfiltered logs.
Padding() As Int
Parent As Object [read only]
Pause
Should be called from Activity_Pause.
RemoveView
RequestFocus As Boolean
Resume
Should be called from Activity_Resume.
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
SIZE_BANNER As Object
320dip x 50dip (default size)
SIZE_IAB_BANNER As Object
468dip x 60dip - tablet only
SIZE_IAB_LEADERBOARD As Object
728dip x 90dip - tablet only
SIZE_IAB_MRECT As Object
300dip x 250dip - tablet only
SIZE_SMART_BANNER As Object
Ad will use the full available width automatically.
You can use this code to add such an ad to the bottom of the screen:

Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
'tablets
height = 90dip
End If
Activity.AddView(AdView1, 0dip, 100%y - height, 100%x, height)
Tag As Object
Top As Int
Visible As Boolean
Width As Int

ConsentManager


Events:

InfoUpdated (Success As Boolean)
FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)

Members:


  AddTestDevice (DeviceId As String)

  ConsentState As String

  Initialize (EventName As String)

  IsRequestLocationInEeaOrUnknown As Boolean [read only]

  RequestInfoUpdate (PublisherIds As List)

  SetDebugGeography (InEea As Boolean)

  ShowConsentForm (PrivacyURL As String, PersonalizedOption As Boolean, NonPersonalizedOption As Boolean, AdFreeOption As Boolean)

  STATE_NON_PERSONALIZED As String

  STATE_PERSONALIZED As String

  STATE_UNKNOWN As String

Members description:

AddTestDevice (DeviceId As String)
Adds a test device id. You can see the current device id in the unfiltered logs.
This allows setting the location with SetDebugGeography.
ConsentState As String
Gets or sets the current consent state. Value will be one of the STATE constants.
Initialize (EventName As String)
IsRequestLocationInEeaOrUnknown As Boolean [read only]
Returns true if the user is located in the European Economic Area or if the location is unknown.
RequestInfoUpdate (PublisherIds As List)
Checks for the current consent state. Raises the InfoUpdated event.
Example:
consent.RequestInfoUpdate(Array("pub-12633333333"))
Wait For consent_InfoUpdated (Success As Boolean)
If Success = False Then
  Log($"Error getting consent state: ${LastException}"$)
End If
SetDebugGeography (InEea As Boolean)
Sets the geographic location for the test devices.
ShowConsentForm (PrivacyURL As String, PersonalizedOption As Boolean, NonPersonalizedOption As Boolean, AdFreeOption As Boolean)
Shows the consent form. Must be called from an activity.
This method should be called when needed, after the current consent state becomes available.
Raises the FormResult event.
PrivacyURL - A link to your privacy URL page.
PersonalizedOption - Whether to show the personalized option.
NonPersonalizedOption - Whether to show the non-personalized option.
AdFreeOption - Whether to show the ad free option.
STATE_NON_PERSONALIZED As String
STATE_PERSONALIZED As String
STATE_UNKNOWN As String

InterstitialAd

Interstitial ads are full screen ads.
The following events are raised:
ReceiveAd - An ad is ready to be shown.
FailedToReceiveAd
AdOpened - The ad has become visible.
AdClosed - The user has closed the ad.
AdLeftApplication - The user has clicked on the ad.
Example of both types of ads using test ids:

Sub Process_Globals

End Sub

Sub Globals
  Private BannerAd As AdView
  Private IAd As InterstitialAd
End Sub

Sub Activity_Create(FirstTime As Boolean)
  Activity.LoadLayout("1")
  BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
  Dim height As Int
  If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
   'phones
   If 100%x > 100%y Then height = 32dip Else height = 50dip
  Else
   'tablets
   height = 90dip
  End If
  Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
  BannerAd.LoadAd
  IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
End Sub

Sub Activity_Resume
  IAd.LoadAd
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_Click
  If IAd.Ready Then IAd.Show Else IAd.LoadAd
End Sub

This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

ReceiveAd
FailedToReceiveAd (ErrorCode As String)
AdClosed
AdOpened
AdLeftApplication

Members:


  Initialize (EventName As String, AdUnitId As String)

  IsInitialized As Boolean

  LoadAd

  LoadAdWithBuilder (Builder As AdRequestBuilder)

  Ready As Boolean [read only]

  Show

Members description:

Initialize (EventName As String, AdUnitId As String)
Initializes the object.
EventName - Set the subs that will handle the events.
AdUnitId - The ad unit id. Test id: ca-app-pub-3940256099942544/1033173712
IsInitialized As Boolean
LoadAd
Requests an ad. The ReceiveAd or FailedToReceiveAd events will be raised.
LoadAdWithBuilder (Builder As AdRequestBuilder)
Requests an ad configured with AdRequestBuilder.
Ready As Boolean [read only]
Tests whether there is an ad ready to be shown.
Show
Shows the loaded ad.

NativeExpressAd


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Permissions:

android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE

Events:

None

Members:


  Background As android.graphics.drawable.Drawable

  BringToFront

  Color As Int [write only]

  Enabled As Boolean

  Height As Int

  Initialize (EventName As String, AdUnitId As String, Width As Float, Height As Float)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  LoadAd

  LoadAdWithBuilder (Builder As AdRequestBuilder)

  LoadAdWithTestDevice (TestDevice As String)

  Padding() As Int

  Parent As Object [read only]

  Pause

  RemoveView

  RequestFocus As Boolean

  Resume

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable

  SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)

  SetVisibleAnimated (arg0 As Int, arg1 As Boolean)

  Tag As Object

  Top As Int

  Visible As Boolean

  Width As Int

Members description:

Background As android.graphics.drawable.Drawable
BringToFront
Color As Int [write only]
Enabled As Boolean
Height As Int
Initialize (EventName As String, AdUnitId As String, Width As Float, Height As Float)
Initializes the ad view.
EventName - Sets the subs that will handle the events.
AdUnitId - Ad unit ID of a native ad.
Width - Requested ad width.
Height - Requested ad height.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
LoadAd
Sends a request to AdMob, requesting an ad.
LoadAdWithBuilder (Builder As AdRequestBuilder)
Requests an ad configured with AdRequestBuilder.
LoadAdWithTestDevice (TestDevice As String)
Requests an ad.
TestDevice - The test device id. You can see the id in the unfiltered logs.
Padding() As Int
Parent As Object [read only]
Pause
Should be called from Activity_Pause.
RemoveView
RequestFocus As Boolean
Resume
Should be called from Activity_Resume.
SendToBack
SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
Tag As Object
Top As Int
Visible As Boolean
Width As Int

RewardedVideoAd

A video ad where the user is rewarded if it is watched fully. The Rewarded event will be raised in that case.
Note that AdMob does not serve these ads directly. You need to use the mediation feature to add an ad network that supports this type of ads.
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

ReceiveAd
FailedToReceiveAd (ErrorCode As String)
AdClosed
AdOpened
AdLeftApplication
Rewarded (Item As Object)

Members:


  Initialize (EventName As String)

  IsInitialized As Boolean

  LoadAd (AdUnitId As String)

  LoadAdWithBuilder (AdUnitId As String, Builder As AdRequestBuilder)

  Ready As Boolean [read only]

  Show

Members description:

Initialize (EventName As String)
IsInitialized As Boolean
LoadAd (AdUnitId As String)
Requests an ad. The ReceiveAd or FailedToReceiveAd events will be raised.
LoadAdWithBuilder (AdUnitId As String, Builder As AdRequestBuilder)
Requests an ad configured with AdRequestBuilder.
Ready As Boolean [read only]
Tests whether there is an ad ready to be shown.
Show
Shows the loaded ad.
Top