Class NativeAdLoader
java.lang.Object
com.codename1.ads.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()));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTrue when the active provider supports native ads.voidload(AdRequest request, AdCallback<NativeAd> onSuccess, AdCallback<AdError> onError) Loads a native ad.
-
Constructor Details
-
NativeAdLoader
Creates a loader for the given ad unit id.
Parameters
adUnitId: the ad unit identifier from the network console
-
-
Method Details
-
isSupported
public static boolean isSupported()True when the active provider supports native ads. -
load
Loads a native ad. Exactly one callback is invoked, on the EDT.
Parameters
request: optional targeting metadata, may be nullonSuccess: invoked with the loaded adonError: invoked on failure
-