NativeAdMapper

public abstract class NativeAdMapper 

Mapping class for Google AdMob native ads.

Mediation adapters that load a native ad must extend this class to provide a mapping from the mediated ad network's native ad object to com.google.android.gms.ads.nativead.NativeAd .

Summary

Public constructors

Public methods

void
destroy ()

Subclasses should implement this method if the mediated network's SDK offers a way to destroy the native ad object.

View

Returns the view being used as AdChoices content.

final String

Returns the text that identifies the advertiser.

final String
getBody ()

Returns body text.

final String

Returns the text that encourages the user to take some action with the ad.

float

Gets the video's current time.

float

Gets the video's duration.

final Bundle

Returns the bundle of extras passed in via the setExtras method.

final String

Returns the primary text headline.

final NativeAd.Image
getIcon ()

Returns a small image identifying the advertiser.

final List < NativeAd.Image >

Returns a list of large images.

float

Returns the aspect ratio of the media to be rendered in the MediaView .

final boolean

Returns true if the ad network does click handling on its own.

final boolean

Returns true if the ad network does impression tracking on its own.

final String

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

final 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.

final String

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

void
handleClick ( View  view)

Subclasses should implement this method if the network requires the developer to explicitly handle click events of views rendered to screen.

boolean

Returns true if the current ad has video content.

void

Subclasses should implement this method if the network requires the developer to explicitly record an impression of a view rendered to screen.

void
setAdChoicesContent ( View  adChoicesContent)

Sets a view to be used as AdChoices content.

final void
setAdvertiser ( String  advertiser)

Sets a text that identifies the advertiser.

final void
setBody ( String  body)

Sets body text.

final void
setCallToAction ( String  callToAction)

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

final void
setExtras ( Bundle  extras)

Sets a bundle of extras containing assets or attributes that do not directly map to those expected for a Google native ad object (headline, body, etc).

void
setHasVideoContent (boolean hasVideoContent)

Set to true if the current ad has video content.

final void
setHeadline ( String  headline)

Sets the primary text headline.

final void

Sets a small image identifying the advertiser.

final void
setImages ( List < NativeAd.Image > images)

Sets a list of large images.

void
setMediaContentAspectRatio (float mediaContentAspectRatio)

Sets the aspect ratio of the media to be rendered in the MediaView .

void
setMediaView ( View  mediaView)

Sets mediated view that displays media.

final void
setOverrideClickHandling (boolean overrideClickHandling)

Set to true if the ad network does click handling on its own.

final void
setOverrideImpressionRecording (boolean overrideImpressionRecording)

Set to true if the ad network does impression tracking on its own.

final void
setPrice ( String  price)

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

final void
setStarRating ( Double  starRating)

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

final void
setStore ( String  store)

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

void
trackViews (
View  containerView,
Map < String View > clickableAssetViews,
Map < String View > nonclickableAssetViews
)

Subclasses should implement this method if the network requires the developer to prepare state for recording an impression and/or click before a view is rendered to screen.

void
untrackView ( View  view)

Subclasses should implement this method if the mediated network's SDK offers a way to stop tracking a native ad view for the ad mapped by this object.

Public fields

adChoicesContent

public  View 
 adChoicesContent 

advertiser

public  String 
 advertiser 

body

public  String 
 body 

callToAction

public  String 
 callToAction 

extras

public  Bundle 
 extras 

headline

public  String 
 headline 

icon

public  NativeAd.Image 
 icon 

images

public  List 
< NativeAd.Image 
 images 

mediaContentAspectRatio

public float  mediaContentAspectRatio 

overrideClickHandling

public boolean  overrideClickHandling 

overrideImpressionRecording

public boolean  overrideImpressionRecording 

price

public  String 
 price 

starRating

public  Double 
 starRating 

store

public  String 
 store 

Public constructors

NativeAdMapper

public  NativeAdMapper 
()

Public methods

destroy

public void  destroy 
()

Subclasses should implement this method if the mediated network's SDK offers a way to destroy the native ad object.

getAdChoicesContent

public  View 
 getAdChoicesContent 
()

Returns the view being used as AdChoices content.

getAdvertiser

public final  String 
 getAdvertiser 
()

Returns the text that identifies the advertiser.

getBody

public final  String 
 getBody 
()

Returns body text.

getCallToAction

public final  String 
 getCallToAction 
()

Returns the text that encourages the user to take some action with the ad.

getCurrentTime

public float  getCurrentTime 
()

Gets the video's current time. Returns zero by default. Subclasses should override this method to return a nonzero current time for video ads.

getDuration

public float  getDuration 
()

Gets the video's duration. Returns zero by default. Subclasses should override this method to return a nonzero duration for video ads.

getExtras

public final  Bundle 
 getExtras 
()

Returns the bundle of extras passed in via the setExtras method.

getHeadline

public final  String 
 getHeadline 
()

Returns the primary text headline.

getIcon

public final  NativeAd.Image 
 getIcon 
()

Returns a small image identifying the advertiser.

getImages

public final  List 
< NativeAd.Image 
 getImages 
()

Returns a list of large images.

getMediaContentAspectRatio

public float  getMediaContentAspectRatio 
()

Returns the aspect ratio of the media to be rendered in the MediaView . Returns zero if the aspect ratio is not available.

getOverrideClickHandling

public final boolean  getOverrideClickHandling 
()

Returns true if the ad network does click handling on its own.

getOverrideImpressionRecording

public final boolean  getOverrideImpressionRecording 
()

Returns true if the ad network does impression tracking on its own.

getPrice

public final  String 
 getPrice 
()

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

getStarRating

public final  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

public final  String 
 getStore 
()

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

handleClick

public void  handleClick 
( View 
 view)

Subclasses should implement this method if the network requires the developer to explicitly handle click events of views rendered to screen.

hasVideoContent

public boolean  hasVideoContent 
()

Returns true if the current ad has video content.

recordImpression

public void  recordImpression 
()

Subclasses should implement this method if the network requires the developer to explicitly record an impression of a view rendered to screen.

setAdChoicesContent

public void  setAdChoicesContent 
( View 
 adChoicesContent)

Sets a view to be used as AdChoices content.

setAdvertiser

public final void  setAdvertiser 
( String 
 advertiser)

Sets a text that identifies the advertiser. Apps are not required to display this asset, though it's recommended.

Parameters
String  advertiser

The text to set

setBody

public final void  setBody 
( String 
 body)

Sets body text. Apps are not required to display this asset, though it's recommended.

Parameters
String  body

The description to set

setCallToAction

public final void  setCallToAction 
( String 
 callToAction)

Sets the ad's call to action (such as "Buy" or "Install"). Apps are not required to display this asset, though it's recommended.

Parameters
String  callToAction

The text to set

setExtras

public final void  setExtras 
( Bundle 
 extras)

Sets a bundle of extras containing assets or attributes that do not directly map to those expected for a Google native ad object (headline, body, etc).

setHasVideoContent

public void  setHasVideoContent 
(boolean hasVideoContent)

Set to true if the current ad has video content.

setHeadline

public final void  setHeadline 
( String 
 headline)

Sets the primary text headline. Apps are required to display this asset.

setIcon

public final void  setIcon 
( NativeAd.Image 
 icon)

Sets a small image identifying the advertiser. Apps are not required to display this asset, though it's recommended.

setImages

public final void  setImages 
( List 
< NativeAd.Image 
> images)

Sets a list of large images. Apps are not required to display this asset, though it's recommended.

setMediaContentAspectRatio

public void  setMediaContentAspectRatio 
(float mediaContentAspectRatio)

Sets the aspect ratio of the media to be rendered in the MediaView .

Parameters
float mediaContentAspectRatio

the aspect ratio to set

setMediaView

public void  setMediaView 
( View 
 mediaView)

Sets mediated view that displays media. This is typically the View provided by the mediated SDK to display video content for an ad, but should display an image asset if no video is present. Adapters are expected to set a View for this property for every ad.

setOverrideClickHandling

public final void  setOverrideClickHandling 
(boolean overrideClickHandling)

Set to true if the ad network does click handling on its own.

setOverrideImpressionRecording

public final void  setOverrideImpressionRecording 
(boolean overrideImpressionRecording)

Set to true if the ad network does impression tracking on its own.

setPrice

public final void  setPrice 
( String 
 price)

For ads about apps, sets a string representing how much the app costs. Apps are not required to display this asset, though it's recommended.

Parameters
String  price

The string representing how much the app costs.

setStarRating

public final void  setStarRating 
( Double 
 starRating)

For ads about apps, sets 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.

setStore

public final void  setStore 
( String 
 store)

For ads about apps, sets 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.

Parameters
String  store

the name of the app store to set

trackViews

public void  trackViews 
(
View  containerView,
Map < String View > clickableAssetViews,
Map < String View > nonclickableAssetViews
)

Subclasses should implement this method if the network requires the developer to prepare state for recording an impression and/or click before a view is rendered to screen. Find the asset names in NativeAdAssetNames .

Parameters
View  containerView

The container View for the ad.

Map < String View > clickableAssetViews

The Map of clickable asset names to corresponding .

Map < String View > nonclickableAssetViews

The Map of non-clickable asset names to corresponding View .

untrackView

public void  untrackView 
( View 
 view)

Subclasses should implement this method if the mediated network's SDK offers a way to stop tracking a native ad view for the ad mapped by this object.

Design a Mobile Site
View Site in Mobile | Classic
Share by: