BaseAdView
public abstract class BaseAdView extends ViewGroup
| java.lang.Object | |||
| ↳ | android.view.View | ||
| ↳ | android.view.ViewGroup | ||
| ↳ | com.google.android.gms.ads.BaseAdView |
AdManagerAdView |
The |
AdView |
The |
The base ad android.view.View for displaying banner ads.
Summary
Protected constructors |
|---|
BaseAdView(Context context, int adViewType)Constructs a |
BaseAdView(Context context, AttributeSet attrs, int adViewType)Constructs a |
BaseAdView(Constructs a |
BaseAdView(Constructs a |
BaseAdView(Constructs a |
Public methods |
|
|---|---|
void |
destroy()Destroys the ad view. |
AdListener |
Returns the |
@Nullable AdSize |
Returns the size of the ad. |
String |
Returns the ad unit ID. |
@Nullable OnPaidEventListener |
Gets the |
long |
Gets the placement ID for this |
@Nullable ResponseInfo |
Returns the |
boolean |
Returns |
boolean |
Returns |
void |
@RequiresPermission(value = Manifest.permission.INTERNET)Loads an ad. |
void |
pause()Pauses any extra processing associated with this ad view. |
void |
resume()Resumes an ad view after a previous call to |
void |
setAdListener(AdListener adListener)Sets an |
void |
Sets the size of the ad. |
void |
setAdUnitId(String adUnitId)Sets the ad unit ID. |
void |
setOnPaidEventListener(@Nullable OnPaidEventListener listener)Registers a callback to be invoked when this ad is estimated to have earned money. |
void |
setPlacementId(long placementId)Sets a placement ID for this ad view. |
Protected methods |
|
|---|---|
void |
onLayout(boolean changed, int left, int top, int right, int bottom) |
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Protected constructors
BaseAdView
protected BaseAdView(Context context, int adViewType)
Constructs a BaseAdView from code.
| Parameters | |
|---|---|
Context context |
The |
BaseAdView
protected BaseAdView(Context context, AttributeSet attrs, int adViewType)
Constructs a BaseAdView from an XML layout.
BaseAdView
protected BaseAdView(
Context context,
AttributeSet attrs,
boolean allowMultipleAdSizes
)
Constructs a BaseAdView from an XML layout.
BaseAdView
protected BaseAdView(
Context context,
AttributeSet attrs,
int defStyle,
int adViewType
)
Constructs a BaseAdView from an XML layout.
BaseAdView
protected BaseAdView(
Context context,
AttributeSet attrs,
int defStyle,
int adViewType,
boolean allowMultipleAdSizes
)
Constructs a BaseAdView from an XML layout.
Public methods
destroy
public void destroy()
Destroys the ad view. This method should be called in the parent Activity's onDestroy method. No other methods should be called on the ad view after destroy is called.
getAdSize
public @Nullable AdSize getAdSize()
Returns the size of the ad. Returns null if setAdSize hasn't been called yet.
ref com.google.android.gms.ads.R.styleable#AdsAttrs_adSize
getAdUnitId
public String getAdUnitId()
Returns the ad unit ID.
ref com.google.android.gms.ads.R.styleable#AdsAttrs_adUnitId
getOnPaidEventListener
public @Nullable OnPaidEventListener getOnPaidEventListener()
Gets the OnPaidEventListener for this ad view.
getResponseInfo
public @Nullable ResponseInfo getResponseInfo()
Returns the ResponseInfo object for the loaded ad. Returns null until the ad successfully loads.
isCollapsible
public boolean isCollapsible()
Returns true if the ad is a collapsible banner; returns false until an ad is loaded.
loadAd
@RequiresPermission(value = Manifest.permission.INTERNET)
public void loadAd(AdRequest adRequest)
Loads an ad.
| Throws | |
|---|---|
java.lang.IllegalStateException |
If the size of the ad or the ad unit ID have not been set. |
pause
public void pause()
Pauses any extra processing associated with this ad view. This method should be called in the parent Activity's onPause method.
resume
public void resume()
Resumes an ad view after a previous call to pause. This method should be called in the parent Activity's onResume method.
setAdSize
public void setAdSize(AdSize adSize)
Sets the size of the ad.
ref com.google.android.gms.ads.R.styleable#AdsAttrs_adSize
| Throws | |
|---|---|
java.lang.IllegalStateException |
If the size of the ad was already set. |
setAdUnitId
public void setAdUnitId(String adUnitId)
Sets the ad unit ID.
ref com.google.android.gms.ads.R.styleable#AdsAttrs_adUnitId
| Throws | |
|---|---|
java.lang.IllegalStateException |
If the ad unit ID was already set. |
setOnPaidEventListener
public void setOnPaidEventListener(@Nullable OnPaidEventListener listener)
Registers a callback to be invoked when this ad is estimated to have earned money.
setPlacementId
public void setPlacementId(long placementId)
Sets a placement ID for this ad view.
To ensure this placement ID is included in reporting, call this method before displaying the ad.
| Parameters | |
|---|---|
long placementId |
A long integer provided by the AdMob UI for the configured placement. |