> 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="/pages/-LGU_vTHE7t_H7tTzmXj#getAdId">getAdId()</a> <br> Get the ad id.</p>                                                                                               |
| String         | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getCampaignId">getCampaignId()</a> <br> Get the campaign id.</p>                                                                             |
| String         | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getEngageUrl">getEngageUrl()</a> <br> Get the engage url.</p>                                                                                |
| int            | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getPlace">getPlace()</a> <br> Get the ad place.</p>                                                                                          |
| String         | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getPlacement">getPlacement()</a> <br> Get the ad placement.</p>                                                                              |
| Rect           | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getSize">getSize()</a> <br> Get the ad size. <br> <strong>You should call this method after ad loaded.</strong></p>                          |
| String         | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getToken">getToken()</a> <br> Get the ad token for tracking.</p>                                                                             |
| long           | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getTotalFileSize">getTotalFileSize()</a> <br> Get the ad file size on device.</p>                                                            |
| String         | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#getVideoCoverPath">getVideoCoverPath()</a> <br> Get video cover file path. <br> <strong>It should be called after onAdLoaded().</strong></p> |
| boolean        | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#hasVideoContent">hasVideoContent()</a> <br> Check if the ad has video content or not.</p>                                                    |
| boolean        | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#isValid">isValid()</a> <br> Check if the ad is still valid for serving.</p>                                                                  |
| void           | <p><a href="/pages/-LGU_vTHE7t_H7tTzmXj#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. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
