Android SDK Version
- AbstractAdListener
- Ad
- AdChoicesView
- AdError
- AdIconView
- AdListener
- AdOptionsView
- AdOptionsView.Orientation
- AdSettings
- AdSettings.IntegrationErrorMode
- AdSettings.MultiprocessSupportMode
- AdSettings.TestAdType
- AdSize
- AdView
- AudienceNetworkActivity
- AudienceNetworkAds
- AudienceNetworkAds.AdFormat
- AudienceNetworkAds.InitListener
- AudienceNetworkAds.InitResult
- AudienceNetworkAds.InitSettingsBuilder
- BidderTokenProvider
- CacheFlag
- DefaultMediaViewVideoRenderer
- ExtraHints
- ExtraHints.Builder
- ExtraHints.HintType
- ExtraHints.Keyword
- InstreamVideoAdListener
- InstreamVideoAdView
- InterstitialAd
- InterstitialAdExtendedListener
- InterstitialAdListener
- MediaView
- MediaViewListener
- MediaViewVideoRenderer
- MediaViewVideoRendererWithBackgroundPlayback
- NativeAd
- NativeAd.AdCreativeType
- NativeAdBase
- NativeAdBase.Image
- NativeAdBase.MediaCacheFlag
- NativeAdBase.NativeComponentTag
- NativeAdBase.Rating
- NativeAdLayout
- NativeAdListener
- NativeAdScrollView
- NativeAdScrollView.AdViewProvider
- NativeAdsManager
- NativeAdsManager.Listener
- NativeAdView
- NativeAdView.Type
- NativeAdViewAttributes
- NativeBannerAd
- NativeBannerAdView
- NativeBannerAdView.Type
- RewardData
- RewardedVideoAd
- RewardedVideoAdExtendedListener
- RewardedVideoAdListener
- S2SRewardedVideoAdExtendedListener
- S2SRewardedVideoAdListener
- VideoAutoplayBehavior
- VideoStartReason
- java.lang.Object
- RelativeLayout
- com.facebook.ads.AdView
All Implemented Interfaces:
public class AdView extends RelativeLayout implements Ad
AdView displays advertisements by Facebook. AdView can be declared and added to view:
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 Summary
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. |
Method Summary
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) |
Constructor Detail
AdView
public AdView(Context context, java.lang.String placementId, AdSize adSize)
Constructs an AdView using the given context, placement_id and size.
Parameters:
context
- Android contextplacementId
- id of ad placementadSize
- size of the ad controlSince:
4.6
AdView
public AdView(Context context, java.lang.String placementId, java.lang.String bidPayload) throws java.lang.Exception
Constructs an AdView using the given context, placement_id and bid payload.
Parameters:
context
- Android contextplacementId
- id of ad placementbidPayload
- the payload supplied with the bidThrows:
java.lang.Exception
Method Detail
setAdListener
public void setAdListener(AdListener adListener)
Sets an AdListener to be notified on events in control lifecycle.
Parameters:
adListener
- the listenerSince:
4.6
loadAd
public void loadAd()
Loads an ad. If the AdView is configured to refresh, this will start the refreshing. There is no need to call this method multiple times. If the AdView is not configured to refresh automatically, it can be refreshed by calling this method again. Each subsequent call should be at least 30 seconds apart. This method always returns immediately. The ad is loaded asynchronously. If available, the ad listener will be called when loading finishes or fails.
loadAdFromBid
public void loadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid. This method always returns immediately. The ad is loaded asynchronously. If available, the ad listener will be called when loading finishes or fails.
Specified by:
loadAdFromBid
in interface Ad
Parameters:
bidPayload
- The payload supplied with the bidSince:
4.28
isAdInvalidated
public boolean isAdInvalidated()
Description copied from interface:
Ad
Indicate whether the ad is still valid.
setExtraHints
public void setExtraHints(ExtraHints extraHints)
Specified by:
setExtraHints
in interface Ad
destroy
public void destroy()
Description copied from interface:
Ad
Destroys the ad control.
This method should be called when the hosting activity of the ad control is destroyed.
getPlacementId
public java.lang.String getPlacementId()
Description copied from interface:
Ad
Get the placementId for this ad.
Specified by:
getPlacementId
in interface Ad
Returns:
placementId String representing the placementId for this ad.
disableAutoRefresh
@Deprecated public void disableAutoRefresh()
Deprecated. auto refresh is no longer supported and therefore this method is now deprecated.
Previously used to disable ads auto refreshing.
Since:
4.6
onConfigurationChanged
protected void onConfigurationChanged(Configuration newConfig)