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 class |
NativeAdBase.Rating
Rating info.
|
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.
|
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.
|
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.MediaCacheFlag mediaCacheFlag)
This method allows to disable pre-caching for the ads while
loadAd() pre-cache ad assets by default. |
void |
loadAdFromBid(java.lang.String bidPayload)
Loads an ad from the payload supplied with a bid.
|
void |
loadAdFromBid(java.lang.String bidPayload,
NativeAdBase.MediaCacheFlag mediaCacheFlag) |
void |
onCtaBroadcast() |
void |
setAdListener(NativeAdListener adListener) |
void |
setExtraHints(ExtraHints extraHints) |
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()
public void setAdListener(NativeAdListener adListener)
adListener
- 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.MediaCacheFlag mediaCacheFlag)
loadAd()
pre-cache ad assets by default.
However, please be aware that once you disable pre-caching, there is a risk
that ad assets might not be loaded in time when an ads is shown at some cases
like unstable internet connection, etc.
As an impression will not be logged until ad media contents are properly shown,
failure to load ad assets in time might result in lagging an impression
even if adView is visible (and possibly not getting an impression at worst case).
In order to check if an impression is logged or not,
please look at AdListener.onLoggingImpression(Ad)
mediaCacheFlag
- pre-cache option for ad assets.public void loadAdFromBid(java.lang.String bidPayload)
Ad
loadAdFromBid
in interface Ad
bidPayload
- The payload supplied with the bidpublic void loadAdFromBid(java.lang.String bidPayload, NativeAdBase.MediaCacheFlag mediaCacheFlag)
public void downloadMedia()
loadAd()
set MediaCacheFlag.ALL by default.
However, if you disabled pre-cache by setting 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 loadAd(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 java.lang.String getAdChoicesLinkUrl()
public java.lang.String getAdChoicesText()
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 NativeAdBase.NativeAdLoadConfigBuilder.loadAd()
after all parameters have been set.