|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.ads.InterstitialAd
public class InterstitialAd
A class for full-screen interstitial ads. Sample code:
public class MyActivity extends Activity implements AdListener { private InterstitialAd interstitialAd; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create an ad. interstitialAd = new InterstitialAd(this, "adUnitId"); // Create an ad request. AdRequest adRequest = new AdRequest(); // Fill out ad request. // Register an AdListener. ad.setAdListener(this); // Start loading the ad in the background. interstitialAd.loadAd(adRequest); } public void onDestroy() { // Stop loading the ad. interstitialAd.stopLoading(); super.onDestroy(); } public void onReceiveAd(Ad ad) { // Be sure to check that it is an InterstitialAd that triggered this // callback. Also, if there are multiple InterstitialAds, make sure it // is the correct one. if (ad == interstitialAd) { // For best performance, make sure you are not performing // processor-intensive or media-intensive operations while showing // interstitial ads. interstitialAd.show(); } } }Another option is to simply call
show()
(which checks isReady()
) when the interstitial should be shown. If
it hasn't loaded by this point, nothing will show.
Constructor Summary | |
---|---|
InterstitialAd(Activity activity,
String adUnitId)
Creates an InterstitialAd with a long load timeout. |
|
InterstitialAd(Activity activity,
String adUnitId,
boolean shortTimeout)
Creates an InterstitialAd. |
Method Summary | |
---|---|
boolean |
isReady()
See Ad.isReady() . |
void |
loadAd(AdRequest adRequest)
Download an ad using the supplied AdRequest . |
void |
setAdListener(AdListener adListener)
Set an AdListener for this InterstitialAd . |
void |
show()
Show the interstitial ad if it's loaded and ready to show. |
void |
stopLoading()
Stops loading the ad. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InterstitialAd(Activity activity, String adUnitId)
activity
- the associated Activity
.adUnitId
- the ad unit ID.public InterstitialAd(Activity activity, String adUnitId, boolean shortTimeout)
shortTimeout
to indicate if the
interstitial should have a short load timeout, making it suitable for use
immediately when an app opens.
activity
- the associated Activity
.adUnitId
- the ad unit ID.shortTimeout
- a flag to indicate that the interstitial should have a
short load timeout value.Method Detail |
---|
public boolean isReady()
Ad.isReady()
.
isReady
in interface Ad
true
if the ad is successfully loaded and is ready to be
shown.Ad.isReady()
public void loadAd(AdRequest adRequest)
AdRequest
.
loadAd
in interface Ad
adRequest
- the AdRequest
used to fetch the ad.public void show()
public void setAdListener(AdListener adListener)
AdListener
for this InterstitialAd
.
setAdListener
in interface Ad
adListener
- the AdListener
.public void stopLoading()
stopLoading
in interface Ad
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |