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

AdMob

List of types:

AdView

AdView

The AdMob library allows you to add ads served by AdMob to your application.
See the AdMob Tutorial.
This library requires some additional configuration as described in the tutorial.
By default the view must be set to a size of 320dip x 50dip. Otherwise it will not display.
Tablets support three additional sizes: IAB_BANNER - 468dip x 60dip, IAB_MRECT - 300dip x 250dip and IAB_LEADERBOARD - 728dip x 90dip.
The size of AdView must match the selected size.
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, PublisherId 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

  Pause

  RemoveView

  RequestFocus As Boolean

  Resume

  SendToBack

  SetBackgroundImage (arg0 As android.graphics.Bitmap)

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

  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, PublisherId As String, Size As Object)
Initializes the AdView.
EventName - Name of Subs that will handle the events.
PublisherId - The publisher id you 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.
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)
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
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

Top