NativeAd

public interface NativeAd extends Ad


A native ad is composed of ad assets that are displayed using Android UI components.

Summary

Nested types

public enum NativeAd.NativeAdType extends Enum

Ad types of a native request.

Media aspect ratio.

Custom click swipe gesture direction.

Public methods

abstract void

Enables publishers reporting clicks using custom gestures for this NativeAd.

abstract AdChoicesInfo

The information for the AdChoices attribution.

abstract NativeAdEventCallback

Callback for receiving native ad lifecycle events.

abstract String

The text that identifies the advertiser.

abstract String

The body text.

abstract String

The ad's call to action (such as "Buy" or "Install").

abstract @NonNull Bundle

Retrieves extras assets associated with a native ad, if set by a mediation partner using com.google.android.gms.ads.mediation.NativeAdMapper.extras.

abstract String

The primary text headline.

abstract Image

A small image identifying the advertiser.

abstract Image

The main image.

abstract @NonNull MediaContent

The media content associated with this ad.

abstract String

For ads about apps, returns a string representing how much the app costs.

abstract Double

For ads about apps, returns a star rating from 0 to 5 representing how many stars the app has in the store offering it.

abstract String

For ads about apps, returns the name of the store offering the app for download.

abstract boolean

Indicates whether clicks can be reported using custom click gestures.

abstract void

Reports clicks for this NativeAd using custom click gesture.

abstract void

Callback for receiving native ad lifecycle events.

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.

Public methods

enableCustomClickGesture

abstract void enableCustomClickGesture()

Enables publishers reporting clicks using custom gestures for this NativeAd. The ad unit must be allowlisted to be able to use this method.

By default SDK tracks clicks on asset views. If this method is called, SDK will no longer track clicks for this NativeAd. It should be called before showing the ad.

getAdChoicesInfo

abstract AdChoicesInfo getAdChoicesInfo()

The information for the AdChoices attribution.

getAdEventCallback

abstract NativeAdEventCallback getAdEventCallback()

Callback for receiving native ad lifecycle events.

getAdvertiser

abstract String getAdvertiser()

The text that identifies the advertiser.

getBody

abstract String getBody()

The body text.

getCallToAction

abstract String getCallToAction()

The ad's call to action (such as "Buy" or "Install").

getExtras

abstract @NonNull Bundle getExtras()

Retrieves extras assets associated with a native ad, if set by a mediation partner using com.google.android.gms.ads.mediation.NativeAdMapper.extras. Returns an empty bundle in non-mediation scenario.

getHeadline

abstract String getHeadline()

The primary text headline.

getIcon

abstract Image getIcon()

A small image identifying the advertiser.

getImage

abstract Image getImage()

The main image.

getMediaContent

abstract @NonNull MediaContent getMediaContent()

The media content associated with this ad.

getPrice

abstract String getPrice()

For ads about apps, returns a string representing how much the app costs.

getStarRating

abstract Double getStarRating()

For ads about apps, returns a star rating from 0 to 5 representing how many stars the app has in the store offering it.

getStore

abstract String getStore()

For ads about apps, returns the name of the store offering the app for download. For example, "Google Play".

isCustomClickGestureEnabled

abstract boolean isCustomClickGestureEnabled()

Indicates whether clicks can be reported using custom click gestures. Reach out to your account manager to allowlist your ad unit for this feature.

recordCustomClickGesture

abstract void recordCustomClickGesture()

Reports clicks for this NativeAd using custom click gesture. The ad unit must be allowlisted to be able to use this method.

enableCustomClickGesture must be called before calling this method.

setAdEventCallback

abstract void setAdEventCallback(NativeAdEventCallback adEventCallback)

Callback for receiving native ad lifecycle events.