public class InterstitialAd extends Object implements Ad
InterstitialAd interstitial = new InterstitialAd(context, PLACEMENT_ID);
interstitial.setAdListener(new InterstitialAdListener() {
public void onAdLoaded(Ad ad) {
if (ad == interstitial) {
interstitial.show();
}
}
// rest of InterstitialAdListener implementation omitted
});
interstitial.loadAd();
InterstitialAd requires InterstitialAdActivity
to be declared
in app's AndroidManifest.xml with android:configChanges="keyboardHidden|orientation".Modifier and Type | Field and Description |
---|---|
static String |
DISPLAY_HEIGHT_INTENT_EXTRA |
static String |
DISPLAY_ROTATION_INTENT_EXTRA |
static String |
DISPLAY_WIDTH_INTENT_EXTRA |
static String |
IMPRESSION_WILL_LOG |
static String |
INTERSTITIAL_CLICKED |
static String |
INTERSTITIAL_DISMISSED |
static String |
INTERSTITIAL_DISPLAYED |
static String |
INTERSTITIAL_UNIQUE_ID_EXTRA |
Constructor and Description |
---|
InterstitialAd(Context context,
String placementId)
Constructs an InterstitialAd using the given context and placement id.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys the ad control.
|
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)
Sets an ImpressionListener to be notified of impression events in ad control lifecycle.
|
boolean |
show()
Shows the interstitial ad.
|
public static final String INTERSTITIAL_DISPLAYED
public static final String INTERSTITIAL_DISMISSED
public static final String INTERSTITIAL_CLICKED
public static final String IMPRESSION_WILL_LOG
public static final String INTERSTITIAL_UNIQUE_ID_EXTRA
public static final String DISPLAY_ROTATION_INTENT_EXTRA
public static final String DISPLAY_WIDTH_INTENT_EXTRA
public static final String DISPLAY_HEIGHT_INTENT_EXTRA
public void setAdListener(InterstitialAdListener adListener)
adListener
- the listenerpublic void setImpressionListener(ImpressionListener impListener)
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 boolean isAdLoaded()
public boolean show()
loadAd()
is called and
the listener is notified ad has been loaded.