public class InterstitialAd extends java.lang.Object implements FullScreenAd
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".Modifier and Type | Class and Description |
---|---|
static interface |
InterstitialAd.InterstitialAdLoadConfigBuilder
Builder that allows to configure an ad loading.
|
static interface |
InterstitialAd.InterstitialAdShowConfigBuilder
Builder that allows to configure an ad showing.
|
static interface |
InterstitialAd.InterstitialLoadAdConfig
Marker interface for an object that represents an interstitial ad load config.
|
static interface |
InterstitialAd.InterstitialShowAdConfig
Marker interface for an object that represents an interstitial ad show config.
|
FullScreenAd.ShowAdConfig, FullScreenAd.ShowConfigBuilder
Ad.LoadAdConfig, Ad.LoadConfigBuilder
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 |
---|---|
InterstitialAd.InterstitialAdLoadConfigBuilder |
buildLoadAdConfig()
Returns
InterstitialAd.InterstitialAdLoadConfigBuilder that allows to specify ad loading parameters. |
InterstitialAd.InterstitialAdShowConfigBuilder |
buildShowAdConfig()
Returns
InterstitialAd.InterstitialShowAdConfig
that allows to specify ad showing parameters. |
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)
Deprecated.
since 5.6, use
loadAd(InterstitialAd.InterstitialLoadAdConfig) |
void |
loadAd(InterstitialAd.InterstitialLoadAdConfig loadAdConfig)
Loads an ad.
|
void |
loadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags,
java.lang.String bidPayload)
Deprecated.
since 5.6, use
loadAd(InterstitialAd.InterstitialLoadAdConfig) |
void |
loadAdFromBid(java.lang.String bidPayload)
Deprecated.
since 5.6, use
loadAd(InterstitialAd.InterstitialLoadAdConfig) |
void |
setAdListener(InterstitialAdListener adListener)
Deprecated.
since 5.6, use
loadAd(InterstitialAd.InterstitialLoadAdConfig) |
void |
setExtraHints(ExtraHints extraHints) |
void |
setRewardedAdListener(RewardedAdListener adListener)
Deprecated.
since 5.6, use
loadAd(InterstitialAd.InterstitialLoadAdConfig) |
boolean |
show()
Shows the interstitial ad.
|
boolean |
show(InterstitialAd.InterstitialShowAdConfig interstitialShowAdConfig)
Shows the interstitial ad
|
public InterstitialAd(Context context, java.lang.String placementId)
context
- Android contextplacementId
- id of ad placement@Deprecated public void setAdListener(InterstitialAdListener adListener)
loadAd(InterstitialAd.InterstitialLoadAdConfig)
adListener
- the listener@Deprecated public void setRewardedAdListener(RewardedAdListener adListener)
loadAd(InterstitialAd.InterstitialLoadAdConfig)
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(InterstitialAd.InterstitialLoadAdConfig loadAdConfig)
This method always returns immediately. The ad is loaded asynchronously. The control's ad listener will be called when loading finishes or fails.
InterstitialAd ad = new InterstitialAd(context, placementId);
InterstitialLoadAdConfig loadAdConfig = ad.buildLoadAdConfig()
.withBid(bidPayload)
.withAdListener(adListener)
.build();
ad.loadAd(loadAdConfig);
@Deprecated public void loadAd(java.util.EnumSet<CacheFlag> cacheFlags)
loadAd(InterstitialAd.InterstitialLoadAdConfig)
cacheFlags
- @Deprecated public void loadAdFromBid(java.lang.String bidPayload)
loadAd(InterstitialAd.InterstitialLoadAdConfig)
Ad
loadAdFromBid
in interface Ad
bidPayload
- The payload supplied with the bid@Deprecated public void loadAdFromBid(java.util.EnumSet<CacheFlag> cacheFlags, java.lang.String bidPayload)
loadAd(InterstitialAd.InterstitialLoadAdConfig)
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.show
in interface FullScreenAd
public boolean show(InterstitialAd.InterstitialShowAdConfig interstitialShowAdConfig)
This method should only be called after loadAd()
is called and the ad listener has been notified ad has loaded
InterstitialShowAdConfig showAdConfig = ad.buildShowAdConfig()
.build();
ad.show(showAdConfig);
interstitialShowAdConfig
- interstitial ad config.public InterstitialAd.InterstitialAdLoadConfigBuilder buildLoadAdConfig()
InterstitialAd.InterstitialAdLoadConfigBuilder
that allows to specify ad loading parameters.
You should call loadAd(InterstitialLoadAdConfig)
after all parameters have been set.buildLoadAdConfig
in interface FullScreenAd
public InterstitialAd.InterstitialAdShowConfigBuilder buildShowAdConfig()
InterstitialAd.InterstitialShowAdConfig
that allows to specify ad showing parameters.
You should call show(InterstitialAd.InterstitialShowAdConfig)
after all parameters have been set.buildShowAdConfig
in interface FullScreenAd