Android SDK Version
  • 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 TypeMethod and Description
voiddestroy()
Destroys the ad control.
voiddisableAutoRefresh()
Deprecated. 
auto refresh is no longer supported and therefore this method is now deprecated.
java.lang.StringgetPlacementId()
Get the placementId for this ad.
booleanisAdInvalidated()
Indicate whether the ad is still valid.
voidloadAd()
Loads an ad.
voidloadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid.
protected voidonConfigurationChanged(Configuration newConfig) 
voidsetAdListener(AdListener adListener)
Sets an AdListener to be notified on events in control lifecycle.
voidsetExtraHints(ExtraHints extraHints) 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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 context
placementId - id of ad placement
adSize - size of the ad control
Since:
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 context
placementId - id of ad placement
bidPayload - the payload supplied with the bid
Throws:
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 listener
Since:
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.
Specified by:
loadAd in interface Ad
Since:
4.6

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 bid
Since:
4.28

isAdInvalidated

public boolean isAdInvalidated()
Description copied from interface: Ad
Indicate whether the ad is still valid.
Specified by:
isAdInvalidated in interface Ad
Returns:
true if the ad is not valid anymore.

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.
Specified by:
destroy in interface Ad
Since:
4.6

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)