public class AdView extends RelativeLayout implements Ad
AdView adView = new AdView(context, PLACEMENT_ID, AdSize.BANNER_HEIGHT_50);
addView(adView);
adView.loadAd();
AdView requires android.permission.INTERNET permission to make network requests.
If android.permission.ACCESS_NETWORK_STATE permission is granted, AdView will only
make network requests when network is connected.Constructor and Description |
---|
AdView(Context context,
java.lang.String placementId,
AdSize adSize)
Constructs an AdView using the given context, placement_id and size.
|
AdView(Context context,
java.lang.String placementId,
java.lang.String bidPayload)
Constructs an AdView using the given context, placement_id and bid payload.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys the ad control.
|
void |
disableAutoRefresh()
Deprecated.
auto refresh is no longer supported and therefore this method is now deprecated.
|
java.lang.String |
getPlacementId()
Get the placementId for this ad.
|
boolean |
isAdInvalidated()
Indicate whether the ad is still valid.
|
void |
loadAd()
Loads an ad.
|
void |
loadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid.
|
protected void |
onConfigurationChanged(Configuration newConfig) |
void |
setAdListener(AdListener adListener)
Sets an AdListener to be notified on events in control lifecycle.
|
void |
setExtraHints(ExtraHints extraHints) |
public AdView(Context context, java.lang.String placementId, AdSize adSize)
context
- Android contextplacementId
- id of ad placementadSize
- size of the ad controlpublic AdView(Context context, java.lang.String placementId, java.lang.String bidPayload) throws java.lang.Exception
context
- Android contextplacementId
- id of ad placementbidPayload
- the payload supplied with the bidjava.lang.Exception
public void setAdListener(AdListener adListener)
adListener
- the listenerpublic void loadAd()
public void loadAdFromBid(java.lang.String bidPayload)
loadAdFromBid
in interface Ad
bidPayload
- The payload supplied with the bidpublic boolean isAdInvalidated()
Ad
isAdInvalidated
in interface Ad
public void setExtraHints(ExtraHints extraHints)
setExtraHints
in interface Ad
public void destroy()
Ad
This method should be called when the hosting activity of the ad control is destroyed.
public java.lang.String getPlacementId()
Ad
getPlacementId
in interface Ad
@Deprecated public void disableAutoRefresh()
protected void onConfigurationChanged(Configuration newConfig)