public abstract class NativeAdBase extends java.lang.Object implements Ad
Modifier and Type | Class and Description |
---|---|
static class |
NativeAdBase.Image
Image creative.
|
static class |
NativeAdBase.MediaCacheFlag
Media Cache flag
|
static interface |
NativeAdBase.NativeAdLoadConfigBuilder
Builder that allows to configure an ad loading.
|
static class |
NativeAdBase.NativeComponentTag
Optional tags for native ad view components.
|
static interface |
NativeAdBase.NativeLoadAdConfig
Marker interface for an object that represents a native ad load config.
|
static class |
NativeAdBase.Rating
Rating info.
|
Ad.LoadAdConfig, Ad.LoadConfigBuilder
Constructor and Description |
---|
NativeAdBase(Context context,
java.lang.String placementId)
Constructs an NativeAdBase using the given context and placement id.
|
NativeAdBase(com.facebook.ads.internal.api.NativeAdBaseApi nativeAdBaseApi)
Used by other SDK classes and subject to change.
|
Modifier and Type | Method and Description |
---|---|
NativeAdBase.NativeAdLoadConfigBuilder |
buildLoadAdConfig()
Returns
NativeAdBase.NativeAdLoadConfigBuilder that allows to specify ad loading parameters. |
void |
destroy()
Destroys the ad control.
|
void |
downloadMedia()
Manually pre-cache media contents such as Image, Icon, video, etc.
|
static NativeAdBase |
fromBidPayload(Context context,
java.lang.String placementId,
java.lang.String bidPayload) |
java.lang.String |
getAdBodyText()
Gets the body, usually a longer description of the ad.
|
java.lang.String |
getAdCallToAction()
Gets the call to action phrase.
|
NativeAdBase.Image |
getAdChoicesIcon() |
java.lang.String |
getAdChoicesImageUrl() |
java.lang.String |
getAdChoicesLinkUrl() |
java.lang.String |
getAdChoicesText() |
NativeAdBase.Image |
getAdCoverImage()
Gets the cover image creative.
|
java.lang.String |
getAdHeadline()
Shows the headline that the advertiser entered when they created an ad; main title of an ad.
|
NativeAdBase.Image |
getAdIcon()
Gets the icon creative.
|
java.lang.String |
getAdLinkDescription()
Shows additional information that the advertiser may have entered.
|
java.lang.String |
getAdSocialContext()
Gets the social context.
|
NativeAdBase.Rating |
getAdStarRating()
Deprecated.
Star rating is deprecated.
|
java.lang.String |
getAdTranslation()
Shows the word 'ad', translated into the regional language
|
java.lang.String |
getAdUntrimmedBodyText()
Gets the untrimmed ad body
|
java.lang.String |
getAdvertiserName()
Shows the name of Facebook Page or mobile app that represents the ad.
|
NativeAdViewAttributes |
getAdViewAttributes()
Deprecated.
|
float |
getAspectRatio()
Aspect ratio of the ad creative.
|
java.lang.String |
getId()
Gets a unique ID for the NativeAd.
|
com.facebook.ads.internal.api.NativeAdBaseApi |
getInternalNativeAd()
Used by other SDK classes and subject to change.
|
java.lang.String |
getPlacementId()
Get the placementId for this ad.
|
Drawable |
getPreloadedIconViewDrawable()
Returns Icon View Drawable preloaded using
NativeAdBase.NativeAdLoadConfigBuilder.withPreloadedIconView(int, int) . |
java.lang.String |
getPromotedTranslation()
Shows the word 'promoted', translated into the regional language
|
java.lang.String |
getSponsoredTranslation()
Shows the word 'Sponsored', translated into the regional language.
|
boolean |
hasCallToAction()
Gets whether an action or command is present in an ad
|
boolean |
isAdInvalidated()
Indicate whether the ad is still valid.
|
boolean |
isAdLoaded()
Gets whether an ad is loaded and ready to show.
|
boolean |
isNativeConfigEnabled()
Deprecated.
|
void |
loadAd()
Loads an ad.
|
void |
loadAd(NativeAdBase.NativeLoadAdConfig loadAdConfig)
Loads an ad.
|
void |
onCtaBroadcast() |
void |
setExtraHints(ExtraHints extraHints)
Deprecated.
|
void |
setOnTouchListener(View.OnTouchListener touchListener)
Sets an OnTouchListener to be notified of touch events on the ad unit.
|
void |
unregisterView() |
public NativeAdBase(Context context, java.lang.String placementId)
context
- Android contextplacementId
- id of ad placementpublic NativeAdBase(com.facebook.ads.internal.api.NativeAdBaseApi nativeAdBaseApi)
public static NativeAdBase fromBidPayload(Context context, java.lang.String placementId, java.lang.String bidPayload) throws java.lang.Exception
java.lang.Exception
public com.facebook.ads.internal.api.NativeAdBaseApi getInternalNativeAd()
@Deprecated public void setExtraHints(ExtraHints extraHints)
setExtraHints
in interface Ad
public void loadAd()
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(NativeAdBase.NativeLoadAdConfig loadAdConfig)
This method always returns immediately. The ad is loaded asynchronously. The control's ad listener will be called when loading finishes or fails.
NativeAd ad = new NativeAd(context, placementId);
ad.loadAd(ad.buildLoadAdConfig()
.withMediaCacheFlag(NativeAdBase.MediaCacheFlag.ALL)
.withPreloadedIconView(width, height)
.build());
public void downloadMedia()
NativeAdBase.MediaCacheFlag.ALL
, this does not need to be called at all. loadAd()
uses NativeAdBase.MediaCacheFlag.ALL
by default. However, if you disabled
pre-cache by using NativeAdBase.MediaCacheFlag.NONE
, then this method needs to be called before
registerViewForInteraction().
Otherwise, you have a risk not getting an impression. For more detail, please look at NativeAdLoadConfigBuilder#withMediaCacheFlag(MediaCacheFlag)
.
public void destroy()
Ad
This method should be called when the hosting activity of the ad control is destroyed.
public java.lang.String getPlacementId()
Ad
getPlacementId
in interface Ad
public boolean isAdInvalidated()
Ad
isAdInvalidated
in interface Ad
public boolean isAdLoaded()
@Deprecated public boolean isNativeConfigEnabled()
public boolean hasCallToAction()
public NativeAdBase.Image getAdIcon()
public NativeAdBase.Image getAdCoverImage()
@Deprecated public NativeAdViewAttributes getAdViewAttributes()
public java.lang.String getAdvertiserName()
public java.lang.String getAdHeadline()
public java.lang.String getAdBodyText()
public java.lang.String getAdUntrimmedBodyText()
public java.lang.String getAdCallToAction()
public java.lang.String getAdSocialContext()
public java.lang.String getAdLinkDescription()
public java.lang.String getSponsoredTranslation()
public java.lang.String getAdTranslation()
public java.lang.String getPromotedTranslation()
@Deprecated public NativeAdBase.Rating getAdStarRating()
public java.lang.String getId()
public NativeAdBase.Image getAdChoicesIcon()
public java.lang.String getAdChoicesImageUrl()
public float getAspectRatio()
public java.lang.String getAdChoicesLinkUrl()
public java.lang.String getAdChoicesText()
public Drawable getPreloadedIconViewDrawable()
NativeAdBase.NativeAdLoadConfigBuilder.withPreloadedIconView(int, int)
.public void onCtaBroadcast()
public void unregisterView()
public void setOnTouchListener(View.OnTouchListener touchListener)
touchListener
- the touch listenerpublic NativeAdBase.NativeAdLoadConfigBuilder buildLoadAdConfig()
NativeAdBase.NativeAdLoadConfigBuilder
that allows to specify ad loading parameters. You
should call loadAd(NativeAdBase.NativeLoadAdConfig)
after all parameters
have been set.