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(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 |
isAdInvalidated()
Indicate whether the ad is still valid.
|
boolean |
isAdLoaded()
Gets whether an ad is loaded and ready to show.
|
void |
loadAd()
Loads an ad.
|
void |
loadAd(java.util.EnumSet<CacheFlag> cacheFlags) |
void |
loadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags,
java.lang.String bidPayload) |
void |
loadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid.
|
void |
setAdListener(InterstitialAdListener adListener)
Sets an InterstitialAdListener to be notified on events in control lifecycle.
|
void |
setExtraHints(ExtraHints extraHints) |
void |
setRewardedAdListener(RewardedAdListener adListener)
Sets a RewardedAdListener to be notified on if user receives a reward.
|
boolean |
show()
Shows the interstitial ad.
|
public InterstitialAd(Context context, java.lang.String placementId)
context
- Android contextplacementId
- id of ad placementpublic void setAdListener(InterstitialAdListener adListener)
adListener
- the listenerpublic void setRewardedAdListener(RewardedAdListener adListener)
adListener
- the listenerpublic void setExtraHints(ExtraHints extraHints)
setExtraHints
in interface Ad
public 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 loadAd(java.util.EnumSet<CacheFlag> cacheFlags)
cacheFlags
- public void loadAdFromBid(java.lang.String bidPayload)
Ad
loadAdFromBid
in interface Ad
bidPayload
- The payload supplied with the bidpublic void loadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags, java.lang.String bidPayload)
public boolean isAdInvalidated()
Ad
isAdInvalidated
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
public boolean isAdLoaded()
public boolean show()
loadAd()
is called and
the listener is notified that the ad has been loaded.