NativeAd provides ad creative for apps to rendered in custom layout.
To use NativeAd, do the following:
NativeAd nativeAd = new NativeAd(context, PLACEMENT_ID); nativeAd.setAdListener(new AbstractAdListener() { public void onAdLoaded(Ad ad) { if (ad == nativeAd) { // Renders the ad using creative properties String adTitle = getAdTitle(); } } }); nativeAd.loadAd();
Before displaying the ad, call NativeAd.registerViewForInteraction(android.view.View viewContainer) to handle logging of ad impressions and clicks.
ขยาย: | Object |
การนำไปใช้: | Ad |
แพ็คเกจ: | ads |
NativeAd(Context, String)
Constructs an NativeAd using the given context and placement id.
public NativeAd(Context context, String placementId)
พารามิเตอร์ | คำอธิบาย |
---|---|
context | Android context |
placementId | Id of ad placement |
NativeAd(Context, NativeAdapter, AdPlacementDefinition)
public NativeAd(Context context, NativeAdapter adapter, AdPlacementDefinition placementDefinition)
พารามิเตอร์ | คำอธิบาย |
---|---|
context | |
adapter | |
placementDefinition |
downloadAndDisplayImage(Image, ImageView)
Downloads the given Image and displays it in the given ImageView.
This method always returns immediately. Image is downloaded asynchronously.
public static void downloadAndDisplayImage(Image image, ImageView imageView)
พารามิเตอร์ | คำอธิบาย |
---|---|
image | Image to be downloaded |
imageView | View to show the downloaded image |
viewIsRegisteredForInteraction(View)
protected static boolean viewIsRegisteredForInteraction(View view)
พารามิเตอร์ | คำอธิบาย |
---|---|
view |
setAdListener(AdListener)
public void setAdListener(AdListener adListener)
พารามิเตอร์ | คำอธิบาย |
---|---|
adListener |
setImpressionListener(ImpressionListener)
public void setImpressionListener(ImpressionListener impListener)
พารามิเตอร์ | คำอธิบาย |
---|---|
impListener | The listener |
loadAd()
Loads an ad.
This method always returns immediately. The ad is loaded asynchronously. The control's ad listener will be called when loading finishes or fails.
public void loadAd()
loadAd()
public void loadAd()
loadAd(EnumSet)
public void loadAd(EnumSet mediaCacheFlags)
พารามิเตอร์ | คำอธิบาย |
---|---|
mediaCacheFlags |
destroy()
Destroys the ad control.
This method should be called when the hosting activity of the ad control is destroyed.
public void destroy()
destroy()
public void destroy()
isAdLoaded()
Gets whether an ad is loaded and ready to show.
public boolean isAdLoaded()
isNativeConfigEnabled()
Gets whether ad config settings are enabled or not
public boolean isNativeConfigEnabled()
getAdIcon()
Gets the icon creative.
public Image getAdIcon()
getAdCoverImage()
Gets the cover image creative.
public Image getAdCoverImage()
getAdViewAttributes()
Gets the ad configuration settings.
public NativeAdViewAttributes getAdViewAttributes()
getAdTitle()
Gets the title.
public String getAdTitle()
getAdSubtitle()
Gets the subtitle.
public String getAdSubtitle()
getAdBody()
Gets the body, usually a longer description of the ad.
public String getAdBody()
getAdCallToAction()
Gets the call to action phrase.
public String getAdCallToAction()
getAdSocialContext()
Gets the social context.
public String getAdSocialContext()
getAdStarRating()
Gets the star rating.
public Rating getAdStarRating()
getId()
Gets a unique ID for the NativeAd.
public String getId()
getAdChoicesIcon()
public Image getAdChoicesIcon()
getAdChoicesLinkUrl()
public String getAdChoicesLinkUrl()
getAdExtras()
public AdExtras getAdExtras()
getCarousel()
public List getCarousel()
registerViewForInteraction(View)
Registers the given view as the container for this NativeAd to handle impressions and clicks. Applies a click handler to the entire unit.
public void registerViewForInteraction(View view)
พารามิเตอร์ | คำอธิบาย |
---|---|
view | The View containing this NativeAd for display |
registerViewForInteraction(View, List)
Registers the given view as the container for this NativeAd to handle impressions and clicks. Applies a click handler all views provided in clickableViews.
public void registerViewForInteraction(View view, List clickableViews)
พารามิเตอร์ | คำอธิบาย |
---|---|
view | The View containing this NativeAd for display |
clickableViews | A list of all view elements that should handle taps on this unit |
setMediaViewAutoplay(boolean)
public void setMediaViewAutoplay(boolean mediaViewAutoplay)
พารามิเตอร์ | คำอธิบาย |
---|---|
mediaViewAutoplay |
unregisterView()
public void unregisterView()
setOnTouchListener(OnTouchListener)
Sets an OnTouchListener to be notified of touch events on the ad unit. Touchable views that can trigger this listener are either the click-able views if a set was provided in registerViewForInteraction(), or the container view provided to registerViewForInteraction() and all of the container's sub-views.
public void setOnTouchListener(OnTouchListener touchListener)
พารามิเตอร์ | คำอธิบาย |
---|---|
touchListener | The touch listener |