public class InterstitialAd extends java.lang.Object implements Ad
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".Constructor and Description |
---|
InterstitialAd(android.content.Context context,
java.lang.String placementId)
Constructs an InterstitialAd using the given context and placement id.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys the ad control.
|
java.lang.String |
getPlacementId()
Get the placementId for this ad.
|
boolean |
isAdLoaded()
Gets whether an ad is loaded and ready to show.
|
void |
loadAd()
Loads an ad.
|
void |
setAdListener(InterstitialAdListener adListener)
Sets an InterstitialAdListener to be notified on events in control lifecycle.
|
void |
setImpressionListener(ImpressionListener impListener)
Deprecated.
See
AbstractAdListener and setAdListener(com.facebook.ads.InterstitialAdListener) .
Sets an ImpressionListener to be notified of impression events in ad control lifecycle. |
boolean |
show()
Shows the interstitial ad.
|
public InterstitialAd(android.content.Context context, java.lang.String placementId)
context
- Android contextplacementId
- id of ad placementpublic void setAdListener(InterstitialAdListener adListener)
adListener
- the listener@Deprecated public void setImpressionListener(ImpressionListener impListener)
AbstractAdListener
and setAdListener(com.facebook.ads.InterstitialAdListener)
.
Sets an ImpressionListener to be notified of impression events in ad control lifecycle.impListener
- the listenerpublic void loadAd()
Ad
This method always returns immediately. The ad is loaded asynchronously. The control's ad listener will be called when loading finishes or fails.
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
public boolean isAdLoaded()
public boolean show()
loadAd()
is called and
the listener is notified ad has been loaded.