> For the complete documentation index, see [llms.txt](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md).

# Ad

**package com.intowow\.sdk**

**public abstract class Ad**

* This class is the parent class of [InterstitialAd](https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/interstitial.html), [DisplayAd](https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/display.html) and [NativeAd](https://github.com/intowow/crystalexpress-documentation-v3-x/tree/eea8a8ed348d77ae2fac3bcbe123fc19fcc36f5c/android/api_reference/native.html).
* You can get more information such as adId, engage url or total file size etc. from `Ad` after `AdListener.onAdLoaded(Ad ad)` is called.
* If you want to get ad size, please call `getSize()` after calling `AdListener.onAdLoaded(Ad ad)`, but for `NativeAd`, you only can get media view size after calling `MediaView.setNativeAd(NativeAd ad)`.

| Public methods |                                                                                                                                                                                                                             |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int            | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getAdId">getAdId()</a> <br> Get the ad id.</p>                                                                                               |
| String         | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getCampaignId">getCampaignId()</a> <br> Get the campaign id.</p>                                                                             |
| String         | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getEngageUrl">getEngageUrl()</a> <br> Get the engage url.</p>                                                                                |
| int            | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getPlace">getPlace()</a> <br> Get the ad place.</p>                                                                                          |
| String         | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getPlacement">getPlacement()</a> <br> Get the ad placement.</p>                                                                              |
| Rect           | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getSize">getSize()</a> <br> Get the ad size. <br> <strong>You should call this method after ad loaded.</strong></p>                          |
| String         | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getToken">getToken()</a> <br> Get the ad token for tracking.</p>                                                                             |
| long           | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getTotalFileSize">getTotalFileSize()</a> <br> Get the ad file size on device.</p>                                                            |
| String         | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#getVideoCoverPath">getVideoCoverPath()</a> <br> Get video cover file path. <br> <strong>It should be called after onAdLoaded().</strong></p> |
| boolean        | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#hasVideoContent">hasVideoContent()</a> <br> Check if the ad has video content or not.</p>                                                    |
| boolean        | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#isValid">isValid()</a> <br> Check if the ad is still valid for serving.</p>                                                                  |
| void           | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md#setSize">setSize(Rect rect)</a> <br> Set the ad size.</p>                                                                                    |

## Public methods

### getAdId <a href="#getadid" id="getadid"></a>

int getAdId()

Get the ad id.

| Returns |            |
| ------- | ---------- |
| int     | the ad id. |

### getCampaignId <a href="#getcampaignid" id="getcampaignid"></a>

String getCampaignId()

Get the campaign id.

| Returns |                                          |
| ------- | ---------------------------------------- |
| String  | the campaign id. This value may be null. |

### getEngageUrl <a href="#getengageurl" id="getengageurl"></a>

String getEngageUrl()

Get the engage url.

| Returns |                                         |
| ------- | --------------------------------------- |
| String  | the engage url. This value may be null. |

### getPlace <a href="#getplace" id="getplace"></a>

int getPlace()

Get the ad place.

| Returns |               |
| ------- | ------------- |
| int     | the ad place. |

### getPlacement <a href="#getplacement" id="getplacement"></a>

String getPlacement()

Get the ad placement.

| Returns |                   |
| ------- | ----------------- |
| String  | the ad placement. |

### getSize <a href="#getsize" id="getsize"></a>

Rect getSize()

Get the ad size. **You should call this method after ad loaded.**

| Returns |                                      |
| ------- | ------------------------------------ |
| Rect    | the ad size. This value may be null. |

### getToken <a href="#gettoken" id="gettoken"></a>

String getToken()

Get the ad token for tracking.

| Returns |                                       |
| ------- | ------------------------------------- |
| String  | the ad token. This value may be null. |

### getTotalFileSize <a href="#gettotalfilesize" id="gettotalfilesize"></a>

long getTotalFileSize()

Get the ad file size on device.

| Returns |               |
| ------- | ------------- |
| long    | the ad token. |

### getVideoCoverPath <a href="#getvideocoverpath" id="getvideocoverpath"></a>

String getVideoCoverPath()

Get video cover file path on device. **It should be called after onAdLoaded().**

| Returns |                                                              |
| ------- | ------------------------------------------------------------ |
| String  | the video cover file path on device. This value may be null. |

### hasVideoContent <a href="#hasvideocontent" id="hasvideocontent"></a>

boolean hasVideoContent()

Check if the ad has video content or not.

| Returns |                                                       |
| ------- | ----------------------------------------------------- |
| boolean | true the ad has video content otherwise return false. |

### isValid <a href="#isvalid" id="isvalid"></a>

boolean isValid()

Check if the ad is still valid for serving.

All of ads from intowow has the expired time (most for 1 hour). If you cache the ad by yourself, be sure to call this method to check the ad is valid before showing the ad. **Otherwise, the impression won't be counted due to the ad creative has expired.**&#x20;

| Returns |                                                                |
| ------- | -------------------------------------------------------------- |
| boolean | true the ad is still valid for serving otherwise return false. |

### setSize <a href="#setsize" id="setsize"></a>

void setWidth(int width)

Set the ad width. **You should call this method before loadAd() if necessary.**

| Parameters |                    |
| ---------- | ------------------ |
| width      | int: the ad width. |
