# CustomNativeAd


```
public interface CustomNativeAd extends Ad
```

<br />

*** ** * ** ***

Custom (user-defined) native ad formats allow you to create your own native ad formats by defining custom lists of assets and the click behavior of the ad.

This feature is available to Ad Manager publishers only.

## Summary

| ### Constants |
|---|---|
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#ASSET_NAME_VIDEO()` The asset name associated with the video content returned by `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#mediaContent()`. |

| ### Public methods |
|---|---|
| `abstract https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/NativeAdEventCallback` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getAdEventCallback()()` Callback for receiving custom native ad lifecycle events. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html>` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getAssetNameSet()()` A set of all available assets, or an empty set if no asset is available. |
| `abstract https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getCustomFormatId()()` The custom native ad format IDs defined in the Ad Manager UI. |
| `abstract https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/DisplayOpenMeasurement` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getDisplayOpenMeasurement()()` Gets the `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/DisplayOpenMeasurement` associated with this ad. |
| `abstract https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Image` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getImage(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName)` Returns an image asset. |
| `abstract https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/MediaContent` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getMediaContent()()` The `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/MediaContent` associated with this ad. |
| `abstract https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/OnCustomClickListener` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getOnCustomClickListener()()` An optional listener to override a custom native ad's click logic. |
| `abstract https://developer.android.com/reference/java/lang/String.html` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#getText(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName)` Returns a string asset of numbers, URLs, or other types other than an image asset. |
| `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#performClick(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName)` Performs a click on the ad, executing its clickthrough behavior. |
| `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#recordImpression()()` Records an impression. |
| `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#setAdEventCallback(com.google.android.libraries.ads.mobile.sdk.nativead.NativeAdEventCallback)(https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/NativeAdEventCallback adEventCallback)` Callback for receiving custom native ad lifecycle events. |
| `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#setOnCustomClickListener(com.google.android.libraries.ads.mobile.sdk.nativead.OnCustomClickListener)(https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/OnCustomClickListener onCustomClickListener)` An optional listener to override a custom native ad's click logic. |

| ### Inherited methods |
|---|
| From [com.google.android.libraries.ads.mobile.sdk.common.Ad](https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad) |---|---| | `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad#destroy()()` Destroys the ad, stopping any extra processing and destroying resources associated with the ad. | | `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/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad#getAdUnitId()()` The ad unit ID used to request this ad. | | `abstract long` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad#getPlacementId()()` An identifier for a placement in reporting. | | `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/ResponseInfo` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad#getResponseInfo()()` Gets information about the ad response for this ad. | | `abstract void` | `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Ad#setPlacementId(kotlin.Long)(long placementId)` An identifier for a placement in reporting. | |

## Constants

### ASSET_NAME_VIDEO

```
default static final @NonNull String ASSET_NAME_VIDEO
```

The asset name associated with the video content returned by `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#mediaContent()`.

This is the asset name reported in CustomNativeAdEventCallback.onCustomClick when the user clicks on the `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/MediaView` containing video content returned by `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#mediaContent()`.

## Public methods

### getAdEventCallback

```
abstract NativeAdEventCallback getAdEventCallback()
```

Callback for receiving custom native ad lifecycle events.

### getAssetNameSet

```
abstract @NonNull Set<@NonNull String> getAssetNameSet()
```

A set of all available assets, or an empty set if no asset is available.

This set includes `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#ASSET_NAME_VIDEO()` if populated.

### getCustomFormatId

```
abstract String getCustomFormatId()
```

The custom native ad format IDs defined in the Ad Manager UI.

### getDisplayOpenMeasurement

```
abstract DisplayOpenMeasurement getDisplayOpenMeasurement()
```

Gets the `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/DisplayOpenMeasurement` associated with this ad. Returns `null` if the custom native ad contains a video asset or does not have Open Measurement enabled.

### getImage

```
abstract Image getImage(@NonNull String assetName)
```

Returns an image asset.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName` | The name of the asset to be retrieved. |

| Returns |
|---|---|
| `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/common/Image` | the value of the asset with the asset name, or null if there's no such asset name. |

### getMediaContent

```
abstract MediaContent getMediaContent()
```

The `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/MediaContent` associated with this ad.

### getOnCustomClickListener

```
abstract OnCustomClickListener getOnCustomClickListener()
```

An optional listener to override a custom native ad's click logic. When set, calls to `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#performClick(kotlin.String)` trigger `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/OnCustomClickListener#onCustomClick(kotlin.String)` instead of navigating to the click URL defined in the Ad Manager UI.

### getText

```
abstract String getText(@NonNull String assetName)
```

Returns a string asset of numbers, URLs, or other types other than an image asset.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName` | The name of the asset to be retrieved. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | the value of the asset with the asset name, or null if there's no such asset name. |

### performClick

```
abstract void performClick(@NonNull String assetName)
```

Performs a click on the ad, executing its clickthrough behavior.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html assetName` | The name of the asset that was clicked. |

### recordImpression

```
abstract void recordImpression()
```

Records an impression. Call this method when the ad is first shown to the user.

### setAdEventCallback

```
abstract void setAdEventCallback(NativeAdEventCallback adEventCallback)
```

Callback for receiving custom native ad lifecycle events.

### setOnCustomClickListener

```
abstract void setOnCustomClickListener(OnCustomClickListener onCustomClickListener)
```

An optional listener to override a custom native ad's click logic. When set, calls to `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/CustomNativeAd#performClick(kotlin.String)` trigger `https://developers.google.com/admob/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/nativead/OnCustomClickListener#onCustomClick(kotlin.String)` instead of navigating to the click URL defined in the Ad Manager UI.