# InterstitialAd

**package com.intowow\.sdk**

**public class InterstitialAd extends Ad**

![](https://1252529651-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGU_q6Cp7glylaa3ogy%2F-LGU_uDXyKLpZsKhgGZa%2F-LGU_wbQ__McDpQn1Ze9%2Fsplash.png?generation=1530612150061999\&alt=media)

### Characteristics

* Takes up the whole screen. Users could engage with the ad or close the ad and back to app.
* Support portrait and landscape mode.
* Support image and video.
* Video is mute by default, and can be toggled by clicking it.

### Recommended Ad Placement

* [Interstitial](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/integration-scenarios/interstitial)

### Request an ad

* Declare InterstitialAdActivity to AndroidManifest.xml

```markup
<activity
  android:name="com.intowow.sdk.InterstitialAdActivity"
  android:configChanges="orientation|screenSize"
  android:launchMode="singleTask"
  android:screenOrientation="portrait"
  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
</activity>
```

* You could request an ad by:

```java
private InterstitialAd mInterstitialAd = null;
private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mInterstitialAd = new InterstitialAd(mActivity);
  RequestInfo requestInfo = new RequestInfo();
  requestInfo.setPlacement(PLACEMENT_NAME);
  requestInfo.setTimeout(LOAD_AD_TIMEOUT);

  mInterstitialAd.setAdListener(new CEInterstitialAdListener() {

    @Override
    public void onAdDisplayed(Ad ad) {
    }

    @Override
    public void onAdDismissed(Ad ad) {
    }

    @Override
    public void onAdClicked(Ad ad) {
    }

    @Override
    public void onAdImpression(Ad ad) {
    }

    @Override
    public void onAdMute(Ad ad) {
    }

    @Override
    public void onAdUnmute(Ad ad) {
    }

    @Override
    public void onVideoEnd(Ad arg0) {
    }

    @Override
    public void onVideoProgress(Ad arg0, int totalDuration, int currentPosition) {
    }

    @Override
    public void onVideoStart(Ad arg0) {
    }

  });

  mInterstitialAd.loadAdAsync(requestInfo, new CEAdRequestListener() {
    @Override
    public void onError(Ad ad, AdError error) {
    }

    @Override
    public void onAdLoaded(Ad ad) {
        if(mInterstitialAd != ad) {
            return;
        }
        //  Start InterstitialAdActivity for showing this ad.
        //
    mInterstitialAd.show();      
    }
  });
}
```

* remember to release ad if it is no longer to use.

```java
@Override
protected void onDestroy() {
    if(mInterstitialAd != null) {
        mInterstitialAd.destroy();
        mInterstitialAd = null;
    }
    ...
    ...
    super.onDestroy();
}
```

### Advance Integration

* If you want the ad to enter the screen with animation effect, please use [show(int enterAnim, int exitAnim)](#show2) after ad loaded.
* If you want to close the interstitial ad after user clicks the ad, please use [setAutoCloseWhenEngaged(boolean isAutoClose)](#setAutoCloseWhenEngaged) before you call [loadAdInstant](#loadadinstant)/[loadAdAsync](#loadadasync).

| Public constructors                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------- |
| <p><a href="#InterstitialAd">InterstitialAd(Context context)</a> <br>Instantiates a new interstitial ad.</p>              |
| <p><a href="#InterstitialAd">InterstitialAd(Context context, Map adProps)</a> <br>Instantiates a new interstitial ad.</p> |

| Public methods                                                                                                            |                                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| void                                                                                                                      | <p><a href="#close">close()</a> <br> Close the InterstitialActivity directly.</p>                                                                                                                                                                                    |
| void                                                                                                                      | <p><a href="#destroy">destroy()</a> <br> Release the interstitial ad.</p>                                                                                                                                                                                            |
| [CERequestResult](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/cerequestresult) | <p><a href="#loadadinstant">loadAdInstant(RequestInfo requestInfo)</a> <br> Load ad with requestInfo (<strong>synchronous</strong>)</p>                                                                                                                              |
| void                                                                                                                      | <p><a href="#loadadasync">loadAdAsync(RequestInfo requestInfo, CEAdRequestListener listener)</a></p><p>Load ad with requestInfo (<strong>asynchronous</strong>)</p>                                                                                                  |
| void                                                                                                                      | <p><a href="#setAdListener">setAdListener(CEInterstitialAdListener listener)</a> <br> Set the ad listener.</p>                                                                                                                                                       |
| void                                                                                                                      | <p><a href="#setAutoCloseWhenEngaged">setAutoCloseWhenEngaged(boolean isAutoClose)</a> <br> Instruct SDK to close the interstitial ad after user clicks the ad. <br> <strong>You should call this method before loadAdInstant/loadAdAsync if necessary.</strong></p> |
| void                                                                                                                      | <p><a href="#show1">show()</a> <br> Start the InterstitialActivity. <br> <strong>You should call this method after onAdLoaded().</strong></p>                                                                                                                        |
| void                                                                                                                      | <p><a href="#show2">show(int enterAnim, int exitAnim)</a> <br> Start the InterstitialActivity with animation effect. <br> <strong>You should call this method after onAdLoaded().</strong></p>                                                                       |

| Inherited methods |                                                                                                                                                                                                                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int               | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getAdId">getAdId()</a> <br> Get the ad id.</p>                                                                                               |
| String            | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getCampaignId">getCampaignId()</a> <br> Get the campaign id.</p>                                                                             |
| String            | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getEngageUrl">getEngageUrl()</a> <br> Get the engage url.</p>                                                                                |
| int               | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getPlace">getPlace()</a> <br> Get the ad place.</p>                                                                                          |
| String            | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getPlacement">getPlacement()</a> <br> Get the ad placement.</p>                                                                              |
| Rect              | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getSize">getSize()</a> <br> Get the ad size. <br> <strong>It should be called after onAdLoaded().</strong></p>                               |
| String            | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getToken">getToken()</a> <br> Get the ad token for tracking.</p>                                                                             |
| long              | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getTotalFileSize">getTotalFileSize()</a> <br> Get the ad file size on device.</p>                                                            |
| String            | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#getVideoCoverPath">getVideoCoverPath()</a> <br> Get video cover file path. <br> <strong>It should be called after onAdLoaded().</strong></p> |
| boolean           | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#hasVideoContent">hasVideoContent()</a> <br> Check if the ad has video content or not.</p>                                                    |
| boolean           | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#isValid">isValid()</a> <br> Check if the ad is still valid for serving.</p>                                                                  |
| void              | <p><a href="https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/ad.html#setSize">setSize(Rect rect)</a> <br> Set the ad size.</p>                                                                                    |

## Public constructors

### InterstitialAd <a href="#interstitialad" id="interstitialad"></a>

InterstitialAd(Context context)

Instantiates a new interstitial ad.

| Parameters |                       |
| ---------- | --------------------- |
| context    | Context: the context. |

## Public methods

### close <a href="#close" id="close"></a>

void close()

Close the InterstitialActivity directly.

### destroy <a href="#destroy" id="destroy"></a>

void destroy()

Release the ad.

### loadAdInstant <a href="#loadadinstant" id="loadadinstant"></a>

[CERequestResult](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/cerequestresult) loadAdInstant(RequestInfo requestInfo)

Load ad with RequestInfo **(synchronous)**

| Parameters  |                                                                                                                                                                    |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| requestInfo | [RequestInfo](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/requestinfo): the request info such as placement and timeout. |

### loadAdAsync <a href="#loadadasync" id="loadadasync"></a>

void loadAdAsync(RequestInfo requestInfo,[ CEAdRequestListene](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceadrequestlistener)r listener)

Load ad with RequestInfo **(asynchronous)**

| Parameters  |                                                                                                                                                                    |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| requestInfo | [RequestInfo](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/requestinfo): the request info such as placement and timeout. |
| listener    | [CEAdRequestListener](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceadrequestlistener): know the result of loadAdAsync  |

### setAdListener <a href="#setadlistener" id="setadlistener"></a>

void setAdListener([CEInterstitialAdListener](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad/interstitialad/ceinterstitialadlistener) listener)

Set the ad listener.

| Parameters |                                                                                                                                                                                 |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| listener   | [CEInterstitialAdListener](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad/interstitialad/ceinterstitialadlistener): the ad listener. |

### setAutoCloseWhenEngaged <a href="#setautoclosewhenengaged" id="setautoclosewhenengaged"></a>

void setAutoCloseWhenEngaged(boolean isAutoClose)

Instruct SDK to close the interstitial ad after user clicks the ad. **You should call this method before loadAdInstant/loadAdAsync if necessary.**

| Parameters  |                                                   |
| ----------- | ------------------------------------------------- |
| isAutoClose | boolean: if auto close when ad is engaged or not. |

### show <a href="#show1" id="show1"></a>

void show()

Start the InterstitialActivity. **You should call this method after onAdLoaded().**

### show <a href="#show2" id="show2"></a>

void show(int enterAnim, int exitAnim)

Start the InterstitialActivity with animation effect. **You should call this method after onAdLoaded().**

| Parameters |                                                                                                        |
| ---------- | ------------------------------------------------------------------------------------------------------ |
| enterAnim  | int: A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation. |
| exitAnim   | int: A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation. |
