---
updatedAt: 2025-11-11T02:13:55.000Z
agentTools:
  projectIndex: https://docs.bidmachine.io/llms.txt
---

# Interstitial

## InterstitialRequest

### Setup InterstitialRequest builder

To create a `InterstitialRequest` instance, you need to create a `InterstitialRequest.Builder` instance, set all the necessary parameters and call `build` on it.

| Type                 | Description                                             |
| :------------------- | :------------------------------------------------------ |
| AdContentType.All    | Flag to request both Video and Static ad content types. |
| AdContentType.Static | Flag to request Static ad content type only.            |
| AdContentType.Video  | Flag to request Video ad content type only.             |

> 📘
>
> By default `AdContentType` is `AdContentType.All`

```java
InterstitialRequest.Builder interstitialRequestBuilder = new InterstitialRequest.Builder()
        .setAdContentType(...) // Set AdContentType
        .setTargetingParams(...) // Set TargatingParams instance
        .setPriceFloorParams(...) // Set price floor parameters
        .setSessionAdParams(...) // Set SessionAdParams instance
        .setLoadingTimeOut(...) // Set loading timeout in milliseconds
        .setPlacementId(...) // Set placement id
```
```kotlin
val interstitialRequestBuilder = InterstitialRequest.Builder()
        .setAdContentType(...) // Set AdContentType
        .setTargetingParams(...) // Set TargatingParams instance
        .setPriceFloorParams(...) // Set price floor parameters
        .setSessionAdParams(...) // Set SessionAdParams instance
        .setLoadingTimeOut(...) // Set loading timeout in milliseconds
        .setPlacementId(...) // Set placement id
```

### Set AdRequestListener

Set the `InterstitialRequest.AdRequestListener` instance to the`InterstitialRequest.Builder` instance.

```java
interstitialRequestBuilder.setListener(new InterstitialRequest.AdRequestListener() {
    
    /**
     * Called when InterstitialRequest was requested successfully
     *
     * @param request       - InterstitialRequest instance
     * @param auctionResult - AuctionResult info
     */
    @Override
    public void onRequestSuccess(@NonNull InterstitialRequest request,
                                 @NonNull AuctionResult auctionResult) {

    }

    /**
     * Called when InterstitialRequest request failed
     *
     * @param request - InterstitialRequest instance
     * @param error   - BMError with additional info about error
     */
    @Override
    public void onRequestFailed(@NonNull InterstitialRequest request,
                                @NonNull BMError error) {
        
    }

    /**
     * Called when InterstitialRequest expired
     *
     * @param request - InterstitialRequest instance
     */
    @Override
    public void onRequestExpired(@NonNull InterstitialRequest request) {
        
    }
  
});
```
```kotlin
interstitialRequestBuilder.setListener(object : InterstitialRequest.AdRequestListener {
    
    /**
     * Called when InterstitialRequest was requested successfully
     *
     * @param request       - InterstitialRequest instance
     * @param auctionResult - AuctionResult info
     */
    override fun onRequestSuccess(request: InterstitialRequest,
                                  auctionResult: AuctionResult) {

    }

    /**
     * Called when InterstitialRequest request failed
     *
     * @param request - InterstitialRequest instance
     * @param error   - BMError with additional info about error
     */
    override fun onRequestFailed(request: InterstitialRequest,
                                 error: BMError) {

    }

    /**
     * Called when InterstitialRequest expired
     *
     * @param request - InterstitialRequest instance
     */
    override fun onRequestExpired(request: InterstitialRequest) {

    }
  
})
```

> 🚧 Note
>
> `AdRequestListener` callbacks are delivered on the background thread, not the main one.

### Build InterstitialRequest

When all the necessary parameters are set, call `build` on the `InterstitialRequest.Builder` instance:

```java
InterstitialRequest interstitialRequest = interstitialRequestBuilder.build();
```
```kotlin
val interstitialRequest = interstitialRequestBuilder.build()
```

> ❗️ Keep ad request
>
> You need to keep reference to `InterstitialRequest` before calling `InterstitialRequest#request`, otherwise, it is possible it will be cleared by Garbage Collector and callbacks won’t be triggered.

### Request InterstitialRequest

When you need to request an ad and get an [`AuctionResult`](https://docs.bidmachine.io/docs/in-house-mediation#auction-result), call `request` on the `InterstitialRequest` instance.

```java
interstitialRequest.request(...);
```
```kotlin
interstitialRequest.request(...)
```

> 📘
>
> When you made an in-house meditation and you decided that an advertisement from BidMachine will be shown - call `interstitialRequest.notifyMediationWin`, if BidMachine lost in mediation - call `interstitialRequest.notifyMediationLoss`

### Destroy InterstitialRequest

Destroy the `InterstitialRequest` instance if you don't need it anymore.

```java
interstitialRequest.destroy();
```
```kotlin
interstitialRequest.destroy()
```

> ❗️
>
> Don't destroy the `InterstitialRequest` instance, if it will be used for load the `InterstitialAd` instance or if the `InterstitialAd` instance loaded with the `InterstitialRequest` instance has not been shown yet.
>
> Otherwise, ad will not work correctly, which can affect a lower display rate, fill rate, rendering errors, and as a result - lower revenue.

## InterstitialAd

### Load InterstitialAd

When you would like to load and display requested Ads:

* Make sure that the `InterstitialRequest` instance have `AuctionResult`. It's mean ads requested successfully.

```java
interstitialRequest.getAuctionResult() != null
```
```kotlin
interstitialRequest.auctionResult != null
```

* Make sure that the`InterstitialRequest` instance not expired.

```java
!interstitialRequest.isExpired()
```
```kotlin
!interstitialRequest.isExpired
```

Before execute `load` on the `InterstitialAd` instance set the `InterstitialListener` instance:

```java
InterstitialAd interstitialAd = new InterstitialAd(...);
interstitialAd.setListener(new InterstitialListener() {
    
    /**
     * Called when Ad was loaded and ready to be displayed
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdLoaded(@NonNull InterstitialAd ad) {

    }

    /**
     * Called when Ad failed to load
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    @Override
    public void onAdLoadFailed(@NonNull InterstitialAd ad,
                               @NonNull BMError error) {

    }

    /**
     * Called when Ad Impression has been tracked
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdImpression(@NonNull InterstitialAd ad) {

    }
  
    /**
     * Called when Ad show failed
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    @Override
    public void onAdShowFailed(@NonNull InterstitialAd ad,
                               @NonNull BMError error) {
    
    }
      
    /**
     * Called when Ad has been clicked
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdClicked(@NonNull InterstitialAd ad) {

    }
  
    /**
     * Called when Ad was closed (e.g - user click close button)
     *
     * @param ad       - InterstitialAd instance
     * @param finished - Value for indicated, if ads was finished (e.g - video playing finished)
     */
    @Override
    public void onAdClosed(@NonNull InterstitialAd ad,
                           boolean finished) {
    
    }

    /**
     * Called when Ad expired
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdExpired(@NonNull InterstitialAd ad) {

    }
  
});
interstitialAd.load(interstitialRequest);
```
```kotlin
val interstitialAd = InterstitialAd(...)
interstitialAd.setListener(object : InterstitialListener {
    
    /**
     * Called when Ad was loaded and ready to be displayed
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdLoaded(ad: InterstitialAd) {

    }

    /**
     * Called when Ad failed to load
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    override fun onAdLoadFailed(ad: InterstitialAd,
                                error: BMError) {

    }

    /**
     * Called when Ad Impression has been tracked
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdImpression(ad: InterstitialAd) {

    }
    
    /**
     * Called when Ad show failed
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    override fun onAdShowFailed(ad: InterstitialAd,
                                error: BMError) {
    
    }
      
    /**
     * Called when Ad has been clicked
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdClicked(ad: InterstitialAd) {

    }
  
    /**
     * Called when Ad was closed (e.g - user click close button)
     *
     * @param ad       - InterstitialAd instance
     * @param finished - Value for indicated, if ads was finished (e.g - video playing finished)
     */
    override fun onAdClosed(ad: InterstitialAd,
                            finished: Boolean) {
    
    }

    /**
     * Called when Ad expired
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdExpired(ad: InterstitialAd) {

    }
  
})
interstitialAd.load(interstitialRequest)
```

Use `onAdLoaded` callback to determine the possibility of displaying

### Show InterstitialAd

Before displaying, check if the `InterstitialAd` instance can be displayed:

```java
interstitialAd.canShow();
```
```kotlin
interstitialAd.canShow()
```

To display the `InterstitialAd` instance, you just need to execute `show`.

```java
interstitialAd.show();
```
```kotlin
interstitialAd.show()
```

### Destroy InterstitialAd

After ad was successful shown and no longer needed, it can be destroyed.

```java
interstitialAd.destroy();
```
```kotlin
interstitialAd.destroy()
```

> 📘 Sample
>
> You can find code examples written in Java and Kotlin: [Github Interstitial](https://github.com/bidmachine/BidMachine-Android-Examples/tree/master/bidmachine-interstitial)