A Google native ad.
Nested Class Summary
class | NativeAd.AdChoicesInfo | Attribution information. | |
class | NativeAd.Image | A native ad image asset. | |
interface | NativeAd.OnNativeAdLoadedListener | Interface definition for a callback to be invoked when a native ad has successfully loaded. | |
interface | NativeAd.UnconfirmedClickListener | A listener interface apps can use to receive unconfirmed click events when using the Confirmed Click feature. |
Public Constructor Summary
NativeAd()
|
Public Method Summary
abstract void |
cancelUnconfirmedClick()
Cancels an unconfirmed click that was previously recorded for the ad.
|
abstract void |
destroy()
Destroys the ad object.
|
abstract void |
enableCustomClickGesture()
This method is deprecated. Use
NativeAdOptions.Builder.enableCustomClickGestureDirection(int,
boolean) .
|
abstract NativeAd.AdChoicesInfo |
getAdChoicesInfo()
Returns the information for the AdChoices attribution.
|
abstractString |
getAdvertiser()
Returns text that identifies the advertiser.
|
abstractString |
getBody()
Returns body text.
|
abstractString |
getCallToAction()
Returns the ad's call to action (such as "Buy" or "Install" ).
|
abstractBundle |
getExtras()
Returns a bundle of extra assets associated with the native ad.
|
abstractString |
getHeadline()
Returns the primary text headline.
|
abstractNativeAd.Image |
getIcon()
Returns a small image identifying the advertiser.
|
abstractList<NativeAd.Image> |
getImages()
Returns a list of large images.
|
abstractMediaContent |
getMediaContent()
Returns the
MediaContent
associated with this ad.
|
abstractList<MuteThisAdReason> |
getMuteThisAdReasons()
Returns Mute This Ad reasons available for this ad.
|
abstractString |
getPrice()
For ads about apps, returns a string representing how much the app costs.
|
abstractResponseInfo |
getResponseInfo()
Returns the
ResponseInfo
object for the loaded ad.
|
abstractDouble |
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.
|
abstractString |
getStore()
For ads about apps, returns the name of the store offering the app for
download.
|
abstract boolean |
isCustomClickGestureEnabled()
This method is deprecated. When loading an ad using
NativeAdOptions.Builder.enableCustomClickGestureDirection(int,
boolean) ,all ads returned will support custom click gesture. If
your account is not allowlisted for this feature, the ad request will no
fill.
|
abstract boolean |
isCustomMuteThisAdEnabled()
Returns
true if this ad can be muted programmatically.
|
abstract void | |
abstract void | |
abstract void |
recordCustomClickGesture()
This method is deprecated. The Google Mobile Ads SDK now tracks custom
click gestures using the click gesture direction requested in
NativeAdOptions.Builder.enableCustomClickGestureDirection(int,
boolean) .
|
abstract boolean | |
abstract void | |
abstract void | |
abstract void |
setOnPaidEventListener(OnPaidEventListener
listener)
Register a callback to be invoked when this ad is estimated to have earned
money.
|
abstract void |
setUnconfirmedClickListener(NativeAd.UnconfirmedClickListener
listener)
Sets the UnconfirmedClickListener for the ad.
|
Inherited Method Summary
Public Constructors
publicNativeAd()
Public Methods
public abstract voidcancelUnconfirmedClick()
Cancels an unconfirmed click that was previously recorded for the ad.
public abstract voiddestroy()
Destroys the ad object. No other methods should be called on the ad object after
destroy
is called.
public abstract voidenableCustomClickGesture()
This method is deprecated.
Use
NativeAdOptions.Builder.enableCustomClickGestureDirection(int, boolean)
.
Enables publishers reporting clicks using custom gestures for thisNativeAd
.
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 thisNativeAd
.
It should be called before showing the ad.
public abstractNativeAd.AdChoicesInfo getAdChoicesInfo()
Returns the information for the AdChoices attribution.
public abstractStringgetAdvertiser()
Returns text that identifies the advertiser. Apps are not required to display this asset, though it's recommended.
public abstractStringgetBody()
Returns body text. Apps are required to display this asset.
public abstractStringgetCallToAction()
Returns the ad's call to action (such as "Buy" or "Install" ). Apps are not required to display this asset, though it's recommended.
public abstractBundlegetExtras()
Returns a bundle of extra assets associated with the native ad. If a mediation
partner's ad have assets besides the standard ones (price, store, etc.), they can be
set by calling the method in
UnifiedNativeAdMapper.setExtras(Bundle)
,and can be retrieved via this
method. For non-mediation flow, it returns an empty bundle.
public abstractStringgetHeadline()
Returns the primary text headline. Apps are required to display this asset.
public abstractNativeAd.Image getIcon()
Returns a small image identifying the advertiser. Apps are not required to display this asset, though it's recommended.
public abstractList<NativeAd.Image> getImages()
Returns a list of large images. Apps are not required to display this asset, though it's recommended.
public abstractMediaContent getMediaContent()
Returns theMediaContent
associated with this ad.
public abstractList<MuteThisAdReason> getMuteThisAdReasons()
Returns Mute This Ad reasons available for this ad. Use the text description from
MuteThisAdReason
class for showing to user.
public abstractStringgetPrice()
For ads about apps, returns a string representing how much the app costs. Apps are not required to display this asset, though it's recommended.
public abstractResponseInfo getResponseInfo()
Returns theResponseInfo
object for the loaded ad. Returnsnull
until the ad successfully
loads.
public abstractDoublegetStarRating()
For ads about apps, returns a star rating from 0 to 5 representing how many stars the app has in the store offering it. Apps are not required to display this asset, though it's recommended.
public abstractStringgetStore()
For ads about apps, returns the name of the store offering the app for download. For example, "Google Play". Apps are not required to display this asset, though it's recommended.
public abstract boolean isCustomClickGestureEnabled()
This method is deprecated.
When loading an ad using
NativeAdOptions.Builder.enableCustomClickGestureDirection(int, boolean)
,all
ads returned will support custom click gesture. If your account is not allowlisted for
this feature, the ad request will no fill.
Indicates whether clicks can be reported using custom click gestures. Reach out to your account manager to allowlist your ad unit for this feature.
public abstract boolean isCustomMuteThisAdEnabled()
Returnstrue
if this ad can be muted programmatically. Use
NativeAdOptions.Builder.setRequestCustomMuteThisAd(boolean)
to request
custom implementation of Mute This Ad.
public abstract voidmuteThisAd(MuteThisAdReason muteThisAdReason)
Mutes This Ad programmatically.
Parameters
muteThisAdReason | The mute reason selected by the user. Get mute reasons from
getMuteThisAdReasons() .Usenull to Mute This Ad with
default reason. |
---|
public abstract voidperformClick(Bundle clickData)
Should be called when the user has clicked on the ad. The ad unit must be allowlisted to be able to use this api. This method should only be used by Unity plugin publishers.
Parameters
clickData | bundle of the app environment when the click happens. For details to construct
the click dataBundle ,see
NativeAdConstants. |
---|
public abstract voidrecordCustomClickGesture()
This method is deprecated.
The Google Mobile Ads SDK now tracks custom click gestures using the click gesture
direction requested in
NativeAdOptions.Builder.enableCustomClickGestureDirection(int, boolean)
.
Reports clicks for thisNativeAd
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.
public abstract boolean recordImpression(Bundle impressionData)
Should be called when the ad is first displayed. The ad unit must be allowlisted to be able to use this api.
Parameters
impressionData | bundle of the app environment when the impression happens. For details to
construct the click dataBundle ,see
NativeAdConstants. |
---|
Returns
- true if the impression is recorded successfully
public abstract voidreportTouchEvent(Bundle touchEventData)
Should be called when a touch event happens on the ad. The ad unit must be allowlisted to be able to use this api. If you are interested in using this feature, reach out to your account manager.
Parameters
touchEventData |
bundle of touch event coordinates and duration.
Example JSON representation of touchEventData Bundle: { "x": "100", // The x-coordinate of the touch event relative to the window. "y": "50", // The y-coordinate of the touch event relative to the window. "duration_millis": "500", // The amount of milliseconds the user pressed on the asset. } |
---|
public abstract voidsetMuteThisAdListener(MuteThisAdListener listener)
Sets theMuteThisAdListener
for the ad.
public abstract voidsetOnPaidEventListener(OnPaidEventListener listener)
Register a callback to be invoked when this ad is estimated to have earned money.
public abstract voidsetUnconfirmedClickListener(NativeAd.UnconfirmedClickListener listener)
Sets the UnconfirmedClickListener for the ad.