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

FirebaseAdMob

List of types:

AdView
InterstitialAd
NativeExpressAd
RewardedVideoAd

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

  LoadAdWithTestDevice (TestDevice As String)

  Parent As Object [read only]

  Pause

  RemoveView

  RequestFocus As Boolean

  Resume

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  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.
LoadAdWithTestDevice (TestDevice As String)
Requests an ad.
TestDevice - The test device id. You can see the id in the unfiltered logs.
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)
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

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

  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.
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

  LoadAdWithTestDevice (TestDevice As String)

  Parent As Object [read only]

  Pause

  RemoveView

  RequestFocus As Boolean

  Resume

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

  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.
LoadAdWithTestDevice (TestDevice As String)
Requests an ad.
TestDevice - The test device id. You can see the id in the unfiltered logs.
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)
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)

  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.
Ready As Boolean [read only]
Tests whether there is an ad ready to be shown.
Show
Shows the loaded ad.
Top