Android SDK Version
- AbstractAdListener
- Ad
- AdChoicesView
- AdError
- AdIconView
- AdListener
- AdOptionsView
- AdOptionsView.Orientation
- AdSettings
- AdSettings.IntegrationErrorMode
- AdSettings.MultiprocessSupportMode
- AdSettings.TestAdType
- AdSize
- AdView
- AudienceNetworkActivity
- AudienceNetworkAds
- AudienceNetworkAds.AdFormat
- AudienceNetworkAds.InitListener
- AudienceNetworkAds.InitResult
- AudienceNetworkAds.InitSettingsBuilder
- BidderTokenProvider
- CacheFlag
- DefaultMediaViewVideoRenderer
- ExtraHints
- ExtraHints.Builder
- ExtraHints.HintType
- ExtraHints.Keyword
- InstreamVideoAdListener
- InstreamVideoAdView
- InterstitialAd
- InterstitialAdExtendedListener
- InterstitialAdListener
- MediaView
- MediaViewListener
- MediaViewVideoRenderer
- MediaViewVideoRendererWithBackgroundPlayback
- NativeAd
- NativeAd.AdCreativeType
- NativeAdBase
- NativeAdBase.Image
- NativeAdBase.MediaCacheFlag
- NativeAdBase.NativeComponentTag
- NativeAdBase.Rating
- NativeAdLayout
- NativeAdListener
- NativeAdScrollView
- NativeAdScrollView.AdViewProvider
- NativeAdsManager
- NativeAdsManager.Listener
- NativeAdView
- NativeAdView.Type
- NativeAdViewAttributes
- NativeBannerAd
- NativeBannerAdView
- NativeBannerAdView.Type
- RewardData
- RewardedVideoAd
- RewardedVideoAdExtendedListener
- RewardedVideoAdListener
- S2SRewardedVideoAdExtendedListener
- S2SRewardedVideoAdListener
- VideoAutoplayBehavior
- VideoStartReason
- java.lang.Object
- com.facebook.ads.NativeAdBase
- com.facebook.ads.NativeAd
All Implemented Interfaces:
public class NativeAd extends NativeAdBase
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 com.facebook.ads.NativeAd#registerViewForInteraction( android.view.View viewContainer, MediaView mediaView)
to handle logging of ad impressions and clicks. Since:
4.6
Nested Class Summary
Modifier and Type | Class and Description |
---|---|
static class | NativeAd.AdCreativeType |
Nested classes/interfaces inherited from class com.facebook.ads.
NativeAdBase.Image, NativeAdBase.MediaCacheFlag, NativeAdBase.NativeComponentTag, NativeAdBase.Rating
Constructor Summary
Constructor and Description |
---|
NativeAd(Context context, NativeAdBase other) Used by other SDK classes and subject to change. |
NativeAd(Context context, com.facebook.ads.internal.api.NativeAdBaseApi nativeAdBaseApi) Used by other SDK classes and subject to change. |
NativeAd(Context context, java.lang.String placementId) Constructs an NativeAd using the given context and placement id. |
Method Summary
Modifier and Type | Method and Description |
---|---|
NativeAd.AdCreativeType | getAdCreativeType() Gets the Ad Creative Type, which can be IMAGE, VIDEO, CAROUSEL or UNKNOWN. |
com.facebook.ads.internal.api.NativeAdApi | getNativeAdApi() Used by other SDK classes and subject to change. |
void | registerViewForInteraction(View view, MediaView mediaView) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
void | registerViewForInteraction(View view, MediaView mediaView, ImageView iconView) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
void | registerViewForInteraction(View view, MediaView mediaView, ImageView iconView, java.util.List<View> clickableViews) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
void | registerViewForInteraction(View view, MediaView mediaView, java.util.List<View> clickableViews) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
void | registerViewForInteraction(View view, MediaView mediaView, MediaView adIconView) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
void | registerViewForInteraction(View view, MediaView mediaView, MediaView adIconView, java.util.List<View> clickableViews) Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. |
Methods inherited from class com.facebook.ads.
destroy, downloadMedia, fromBidPayload, getAdBodyText, getAdCallToAction, getAdChoicesIcon, getAdChoicesImageUrl, getAdChoicesLinkUrl, getAdChoicesText, getAdCoverImage, getAdHeadline, getAdIcon, getAdLinkDescription, getAdSocialContext, getAdStarRating, getAdTranslation, getAdUntrimmedBodyText, getAdvertiserName, getAdViewAttributes, getId, getInternalNativeAd, getPlacementId, getPromotedTranslation, getSponsoredTranslation, hasCallToAction, isAdInvalidated, isAdLoaded, isNativeConfigEnabled, loadAd, loadAd, loadAdFromBid, loadAdFromBid, onCtaBroadcast, setAdListener, setExtraHints, setOnTouchListener, unregisterView
Constructor Detail
NativeAd
public NativeAd(Context context, java.lang.String placementId)
Constructs an NativeAd using the given context and placement id.
Parameters:
context
- Android contextplacementId
- id of ad placementSince:
4.6
NativeAd
public NativeAd(Context context, com.facebook.ads.internal.api.NativeAdBaseApi nativeAdBaseApi)
Used by other SDK classes and subject to change.
NativeAd
public NativeAd(Context context, NativeAdBase other)
Used by other SDK classes and subject to change.
Since:
4.6
Method Detail
getNativeAdApi
public com.facebook.ads.internal.api.NativeAdApi getNativeAdApi()
Used by other SDK classes and subject to change.
getAdCreativeType
public NativeAd.AdCreativeType getAdCreativeType()
Gets the Ad Creative Type, which can be IMAGE, VIDEO, CAROUSEL or UNKNOWN.
Returns:
the
NativeAd.AdCreativeType
of the current Native Ad if the ad is loaded. Otherwise returns UNKNOWN.registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit.
Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.Since:
4.99
registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView, MediaView adIconView)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit.
Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.adIconView
- optional MediaView
to display Icon.Since:
4.99
registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView, java.util.List<View> clickableViews)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit.
Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.clickableViews
- a list of all view elements that should handle taps on this unitSince:
4.99
registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView, MediaView adIconView, java.util.List<View> clickableViews)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit.
Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.adIconView
- optional MediaView
to display Icon.clickableViews
- a list of all view elements that should handle taps on this unitSince:
4.99
registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView, ImageView iconView)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit. We recommend use
MediaView
for ad icon, but for Mediation platform users, ImageView
is also supported for Native Ad's ad Icon.Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.iconView
- optional imageView for ad Icon.Since:
5.0
registerViewForInteraction
public void registerViewForInteraction(View view, MediaView mediaView, ImageView iconView, java.util.List<View> clickableViews)
Registers the given view as the container and the required MediaView as the contents display for this NativeAd to handle impressions and clicks. MediaView must be within the view passed as the container for this NativeAd. Applies a click handler to the entire unit. We recommend use
MediaView
for ad icon, but for Mediation platform users, ImageView
is also supported for Native Ad's ad Icon.Parameters:
view
- the View containing this NativeAd for displaymediaView
- MediaView to display contents such as video, carousel, etc.iconView
- optional imageView for ad Icon.clickableViews
- a list of all view elements that should handle taps on this unitSince:
5.0