public class NativeAdLoader

  1. Object
  2. NativeAdLoader

Loads NativeAd assets that you render with your own components, so the ad matches the look and feel of the surrounding content. This is the format to use in content driven apps - a news or social feed, a store listing, a chat or a search results screen - where a banner would feel bolted on but a list row styled like the others reads naturally (and must be clearly labelled “Ad”/“Sponsored”).

Native ads are an optional provider capability; if the active provider does not support them the error callback receives an AdError with code AdError.CODE_UNSUPPORTED.

new NativeAdLoader("ca-app-pub-xxx/yyy").load(null,
    ad -> feed.addComponent(buildSponsoredRow(ad)),
    err -> Log.p(err.toString()));

Constructors

public NativeAdLoader(String adUnitId)Creates a loader for the given ad unit id.

Methods

public static boolean isSupported()True when the active provider supports native ads.
public void load(AdRequest request, AdCallback<NativeAd> onSuccess, AdCallback<AdError> onError)Loads a native ad.

Inherited methods

Constructor details

NativeAdLoader

public NativeAdLoader(String adUnitId)
Creates a loader for the given ad unit id.

Parameters

adUnitId String
the ad unit identifier from the network console

Method details

isSupported

public static boolean isSupported()
True when the active provider supports native ads.

load

public void load(AdRequest request, AdCallback<NativeAd> onSuccess, AdCallback<AdError> onError)
Loads a native ad. Exactly one callback is invoked, on the EDT.

Parameters

request AdRequest
optional targeting metadata, may be null
onSuccess AdCallback<NativeAd>
invoked with the loaded ad
onError AdCallback<AdError>
invoked on failure