Android SDK Version
  • java.lang.Object
    • com.facebook.ads.InterstitialAd
All Implemented Interfaces:

public class InterstitialAd
extends java.lang.Object
implements Ad
InterstitialAd displays an advertisement by Facebook in an interstitial.
To use the interstitial, do the following:
 InterstitialAd interstitial = new InterstitialAd(context, PLACEMENT_ID); interstitial.setAdListener(new AbstractAdListener() { public void onAdLoaded(Ad ad) { if (ad == interstitial) { interstitial.show(); } } }); interstitial.loadAd(); 
InterstitialAd requires AudienceNetworkActivity to be declared in app's AndroidManifest.xml with android:configChanges="keyboardHidden|orientation".
Since:
4.6
Constructor Summary
Constructor and Description
InterstitialAd(Context context, java.lang.String placementId)
Constructs an InterstitialAd using the given context and placement id.
Method Summary
Modifier and TypeMethod and Description
voiddestroy()
Destroys the ad control.
java.lang.StringgetPlacementId()
Get the placementId for this ad.
booleanisAdInvalidated()
Indicate whether the ad is still valid.
booleanisAdLoaded()
Gets whether an ad is loaded and ready to show.
voidloadAd()
Loads an ad.
voidloadAd(java.util.EnumSet<CacheFlag> cacheFlags) 
voidloadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags, java.lang.String bidPayload) 
voidloadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid.
voidsetAdListener(InterstitialAdListener adListener)
Sets an InterstitialAdListener to be notified on events in control lifecycle.
voidsetExtraHints(ExtraHints extraHints) 
booleanshow()
Shows the interstitial ad.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail

InterstitialAd

public InterstitialAd(Context context,
                      java.lang.String placementId)
Constructs an InterstitialAd using the given context and placement id.
Parameters:
context - Android context
placementId - id of ad placement
Since:
4.6
Method Detail

setAdListener

public void setAdListener(InterstitialAdListener adListener)
Sets an InterstitialAdListener to be notified on events in control lifecycle.
Parameters:
adListener - the listener
Since:
4.6

setExtraHints

public void setExtraHints(ExtraHints extraHints)
Specified by:
setExtraHints in interface Ad

loadAd

public void loadAd()
Description copied from interface: Ad
Loads an ad.
This method always returns immediately. The ad is loaded asynchronously. The control's ad listener will be called when loading finishes or fails.
Specified by:
loadAd in interface Ad
Since:
4.6

loadAd

public void loadAd(java.util.EnumSet<CacheFlag> cacheFlags)
Parameters:
cacheFlags -
Since:
4.23

loadAdFromBid

public void loadAdFromBid(java.lang.String bidPayload)
Description copied from interface: Ad
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

loadAdFromBid

public void loadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags,
                          java.lang.String bidPayload)

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.

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.

isAdLoaded

public boolean isAdLoaded()
Gets whether an ad is loaded and ready to show.
Returns:
whether an ad is loaded
Since:
4.6

show

public boolean show()
Shows the interstitial ad.
This method should only be called after loadAd() is called and the listener is notified ad has been loaded.
Returns:
false if no ad is loaded, otherwise true
Since:
4.6