CustomNativeAd

public interface CustomNativeAd extends Ad


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 @NonNull String

The asset name associated with the video content returned by mediaContent.

Public methods

abstract NativeAdEventCallback

Callback for receiving custom native ad lifecycle events.

abstract @NonNull Set<@NonNull String>

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

abstract String

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

abstract DisplayOpenMeasurement

Gets the DisplayOpenMeasurement associated with this ad.

abstract Image
getImage(@NonNull String assetName)

Returns an image asset.

abstract MediaContent

The MediaContent associated with this ad.

abstract OnCustomClickListener

An optional listener to override a custom native ad's click logic.

abstract String
getText(@NonNull String assetName)

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

abstract void

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

abstract void

Records an impression.

abstract void

Callback for receiving custom native ad lifecycle events.

abstract void

An optional listener to override a custom native ad's click logic.

Inherited methods

From com.google.android.libraries.ads.mobile.sdk.common.Ad
abstract void

Destroys the ad, stopping any extra processing and destroying resources associated with the ad.

abstract long

An identifier for a placement in reporting.

abstract @NonNull ResponseInfo

Gets information about the ad response for this ad.

abstract void
setPlacementId(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 mediaContent.

This is the asset name reported in CustomNativeAdEventCallback.onCustomClick when the user clicks on the MediaView containing video content returned by mediaContent.

Public methods

getAdEventCallback

abstract NativeAdEventCallback getAdEventCallback()

Callback for receiving custom native ad lifecycle events.

getAssetNameSet

abstract @NonNull Set<@NonNull StringgetAssetNameSet()

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

This set includes 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 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
@NonNull String assetName

The name of the asset to be retrieved.

Returns
Image

the value of the asset with the asset name, or null if there's no such asset name.

getMediaContent

abstract MediaContent getMediaContent()

The 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 performClick trigger OnCustomClickListener.onCustomClick 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
@NonNull String assetName

The name of the asset to be retrieved.

Returns
String

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
@NonNull String 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 performClick trigger OnCustomClickListener.onCustomClick instead of navigating to the click URL defined in the Ad Manager UI.