# InterstitialAd

# InterstitialAd


```
public abstract class InterstitialAd
```

<br />

Known direct subclasses [AdManagerInterstitialAd](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/admanager/AdManagerInterstitialAd)

|---|---|
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/admanager/AdManagerInterstitialAd` | A full page ad experience at natural transition points such as a page change, an app launch, or a game level load for Google Ad Manager publishers. |

*** ** * ** ***

A full page ad experience at natural transition points such as a page change, an app launch, or a game level load. Interstitials use a close button that removes the ad from the user's experience.

Sample code:

```
public class MyActivity extends Activity {
    private InterstitialAd interstitialAd;
    private Button nextLevelButton;
    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create a full screen content callback.
        FullScreenContentCallback fullScreenContentCallback = new FullScreenContentCallback() {
            @Override
            public void onAdDismissedFullScreenContent() {
               interstitialAd = null;
               // Proceed to the next level.
               goToNextLevel();
            }
        };

        // Load an interstitial ad. When a natural transition in the app occurs (such as a level
        // ending in a game), show the interstitial. In this simple example, the press of a
        // button is used instead.
        //
        // If the button is clicked before the interstitial is loaded, the user should proceed to
        // the next part of the app (in this case, the next level).
        //
        // If the interstitial is finished loading, the user will view the interstitial before
        // proceeding.
        InterstitialAd.load(
            this,
            "myAdUnitId",
            new AdRequest.Builder().build(),
            new InterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull InterstitialAd ad) {
                    interstitialAd = ad;
                    interstitialAd.setFullScreenContentCallback(fullScreenContentCallback);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError adError) {
                    // Code to be executed when an ad request fails.
                }
            });

        // Create the button to go to the next level.
        nextLevelButton = new Button(this);
        nextLevelButton.setText("Next Level");
        nextLevelButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Show the interstitial if it is ready. Otherwise, proceed to the next level
                // without ever showing it.
                if (interstitialAd != null) {
                    interstitialAd.show(MyActivity.this);
                } else {
                    // Proceed to the next level.
                    goToNextLevel();
                }
            }
        });

        // Add the next level button to the layout.
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(nextLevelButton);

        // Create a TextView to display the current level.
        textView = new TextView(this);
        textView.setText("Level 1");
        layout.addView(textView);

        setContentView(layout);
    }

    public void goToNextLevel() {
        // Show the next level, and disable the next level button since there are no more levels.
        nextLevelButton.setEnabled(false);
        textView.setText("Level 2");
    }
}
```

## Summary

| ### Public constructors |
|---|
| `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#InterstitialAd()()` |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#getAdUnitId()()` Returns the ad unit ID. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/FullScreenContentCallback` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#getFullScreenContentCallback()()` Gets the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/FullScreenContentCallback` for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/OnPaidEventListener` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#getOnPaidEventListener()()` Gets the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/OnPaidEventListener` for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`. |
| `abstract long` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#getPlacementId()()` Returns the placement ID for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/ResponseInfo` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#getResponseInfo()()` Returns the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/ResponseInfo` object for the loaded ad. |
| `static boolean` | `[isAdAvailable](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#isAdAvailable(android.content.Context,java.lang.String))(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html adUnitId)` **This method is deprecated.** Use `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdPreloader#isAdAvailable(java.lang.String)` instead. <br /> |
| `static void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#load(android.content.Context,java.lang.String,com.google.android.gms.ads.AdRequest,com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html adUnitId, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest adRequest, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdLoadCallback loadCallback )` Loads an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd` | `[pollAd](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#pollAd(android.content.Context,java.lang.String))(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html adUnitId)` **This method is deprecated.** Use `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdPreloader#pollAd(java.lang.String)` instead. <br /> |
| `abstract void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#setFullScreenContentCallback(com.google.android.gms.ads.FullScreenContentCallback)( @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/FullScreenContentCallback fullScreenContentCallback )` Registers a callback to be invoked when ads show and dismiss full screen content. |
| `abstract void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#setImmersiveMode(boolean)(boolean immersiveModeEnabled)` Sets a flag that controls if this interstitial object will be displayed in immersive mode. |
| `abstract void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#setOnPaidEventListener(com.google.android.gms.ads.OnPaidEventListener)(@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/OnPaidEventListener listener)` Registers a callback to be invoked when this ad is estimated to have earned money. |
| `abstract void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#setPlacementId(long)(long placementId)` Sets a placement ID for the interstitial ad. |
| `abstract void` | `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#show(android.app.Activity)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity)` Shows the interstitial ad. |

## Public constructors

### InterstitialAd

```
public InterstitialAd()
```

## Public methods

### getAdUnitId

```
public abstract @NonNull String getAdUnitId()
```

Returns the ad unit ID.

### getFullScreenContentCallback

```
public abstract @Nullable FullScreenContentCallback getFullScreenContentCallback()
```

Gets the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/FullScreenContentCallback` for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`.

### getOnPaidEventListener

```
public abstract @Nullable OnPaidEventListener getOnPaidEventListener()
```

Gets the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/OnPaidEventListener` for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`.

### getPlacementId

```
public abstract long getPlacementId()
```

Returns the placement ID for this `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`.

### getResponseInfo

```
public abstract @NonNull ResponseInfo getResponseInfo()
```

Returns the `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/ResponseInfo` object for the loaded ad. Returns `null` until the ad successfully loads.

### isAdAvailable

```
public static boolean [isAdAvailable](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#isAdAvailable(android.content.Context,java.lang.String))(@NonNull Context context, @NonNull String adUnitId)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdPreloader#isAdAvailable(java.lang.String)` instead.

Returns `true` if there is an available interstitial ad loaded from `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/MobileAds#startPreload(android.content.Context,java.util.List<com.google.android.gms.ads.preload.PreloadConfiguration>,com.google.android.gms.ads.preload.PreloadCallback)`.

### load

```
public static void load(
    @NonNull Context context,
    @NonNull String adUnitId,
    @NonNull AdRequest adRequest,
    @NonNull InterstitialAdLoadCallback loadCallback
)
```

Loads an `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | An activity or application context. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html adUnitId` | The ad unit ID. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/AdRequest adRequest` | An ad request with targeting information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdLoadCallback loadCallback` | A callback to be invoked when an interstitial ad finishes loading. |

### pollAd

```
public static @Nullable InterstitialAd [pollAd](https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#pollAd(android.content.Context,java.lang.String))(@NonNull Context context, @NonNull String adUnitId)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAdPreloader#pollAd(java.lang.String)` instead.

Retrieves the next interstitial ad loaded from `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/MobileAds#startPreload(android.content.Context,java.util.List<com.google.android.gms.ads.preload.PreloadConfiguration>,com.google.android.gms.ads.preload.PreloadCallback)`, or `null` if no ad is available.

### setFullScreenContentCallback

```
public abstract void setFullScreenContentCallback(
    @Nullable FullScreenContentCallback fullScreenContentCallback
)
```

Registers a callback to be invoked when ads show and dismiss full screen content.

### setImmersiveMode

```
public abstract void setImmersiveMode(boolean immersiveModeEnabled)
```

Sets a flag that controls if this interstitial object will be displayed in immersive mode. Call this method before `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#show(android.app.Activity)`. During `https://developers.google.com/admob/android/reference/com/google/android/gms/ads/interstitial/InterstitialAd#show(android.app.Activity)`, if this flag is on and immersive mode is supported, SYSTEM_UI_FLAG_IMMERSIVE_STICKY \&SYSTEM_UI_FLAG_HIDE_NAVIGATION will be turned on for interstitial ad.

### setOnPaidEventListener

```
public abstract void setOnPaidEventListener(@Nullable OnPaidEventListener listener)
```

Registers a callback to be invoked when this ad is estimated to have earned money.

### setPlacementId

```
public abstract void setPlacementId(long placementId)
```

Sets a placement ID for the interstitial ad.

To ensure this placement ID is included in reporting, call this method before showing the ad.

| Parameters |
|---|---|
| `long placementId` | A long integer provided by the AdMob UI for the configured placement. |

### show

```
public abstract void show(@NonNull Activity activity)
```

Shows the interstitial ad.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | An `Activity` context from which to present the ad. |