Class NativeAd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceNativeAd.CollageItemsShowHandlerInterface for handling collage item showing
public interfaceNativeAd.NativeAdChoicesListenerpublic interfaceNativeAd.NativeAdChoicesOptionListenerpublic interfaceNativeAd.NativeAdListenerpublic interfaceNativeAd.NativeAdMediaListenerpublic interfaceNativeAd.NativeAdVideoListenerpublic interfaceNativeAd.NativeAdVideoPlayerInterface for managing native ad video player
-
Constructor Summary
Constructors Constructor Description NativeAd(int slotId, Context context)Public constructor NativeAd(int slotId, MenuFactory menuFactory, Context context)Public constructor
-
Method Summary
Modifier and Type Method Description NativeAd.NativeAdChoicesListenergetAdChoicesListener()NativeAd.NativeAdChoicesOptionListenergetAdChoicesOptionListener()Returns listener for ad choice menu. intgetAdChoicesPlacement()Retrieve current position for AdChoices icon StringgetAdSource()Get the name of source network. floatgetAdSourcePriority()Ad Source Priority is the value representing current ad network place in the queue of received advertisements. NativePromoBannergetBanner()Banner model for current ad. intgetCachePolicy()Retrieve current cachePolicy set previously booleangetHtml5ContentIsLoaded()NativeAd.NativeAdListenergetListener()Get events listener of an advertisement NativeAd.NativeAdMediaListenergetMediaListener()Gets listener for media objects events, such as icon loading NativeAd.NativeAdVideoListenergetNativeAdVideoListener()Get events listener of an native ad video NativeAd.NativeAdVideoPlayergetNativeAdVideoPlayer()intgetVideoQuality()Gets desired video quality of loading video. voidhandleAdChoicesClick(@NonNull() Context context)Call to display adChoices options whose implementation has been passed using MenuFactory. voidhandleClick(boolean isCta, @NonNull() View view)Call to trigger click on a view manually. voidhandleData(@NonNull() String data)Loads data for s2s partners booleanisMediationEnabled()Get enable/disable mediation flag booleanisUseExoPlayer()Gets current flag of using ExoPlayer (androidx. voidload()Start loading ads. voidloadFromBid(@NonNull() String bidId)Start loading ad with the bidding ID voidregisterView(@NonNull() View view)Registration of the Advertising view. voidregisterView(@NonNull() View view, @Nullable() List<View> clickableViews)Registration of the Advertising view. voidregisterView(@NonNull() NativeAdViewBinder nativeAdViewBinder)Registration of the Advertising view via NativeAdViewBinder. voidregisterView(@NonNull() NativeAdViewBinder nativeAdViewBinder, @Nullable() List<View> clickableViews)Registration of the Advertising view via NativeAdViewBinder. voidregisterView(@NonNull() NativeAdView nativeAdView)Registration of the Advertising view. voidregisterView(@NonNull() NativeAdView nativeAdView, @Nullable() List<View> clickableViews)Registration of the Advertising view. voidreloadHtmlContent()Reload Html5 content, if it exists and it was loaded before, nothing will happen otherwise. voidsetAdChoicesListener(@Nullable() NativeAd.NativeAdChoicesListener adChoicesListener)Set events listener of adChoices icon load Must be called before NativeAd.load() voidsetAdChoicesOptionListener(@Nullable() NativeAd.NativeAdChoicesOptionListener adChoicesOptionListener)voidsetAdChoicesPlacement(int adChoicesPlacement)Sets the place for AdChoices icon, by default used top-right position voidsetAdsLightPixelParams(@NonNull() String adsLightType, @Nullable() Map<String, String> params)Method for internal partners voidsetCachePolicy(int cachePolicy)By default, images and videos are preloaded. voidsetCollageItemsShowHandler(@Nullable() NativeAd.CollageItemsShowHandler collageItemsShowHandler)Set collage items show handler Must be called before NativeAd.load() voidsetHtmlCustomEventListener(@Nullable() HtmlCustomEventListener listener)Sets listener for HTML5 interactive in order to receive callbacks about custom events voidsetHtmlInteractionListener(@Nullable() HtmlInteractionListener listener)Set user interaction listener for Html5 content. voidsetHtmlInteractiveProgressListener(@NonNull() HtmlInteractiveProgressListener listener)Set progress listener for Html5 interactive progress. voidsetHtmlLoadingListener(@Nullable() HtmlLoadingListener listener)Set loading listener for Html5 content. voidsetHtmlLoadingTimeoutMillis(long loadingTimeoutMillis)Sets timeout for HTML5 content loading. voidsetInternalObject(@NonNull() Object internalObject)Method for internal partners voidsetListener(@Nullable() NativeAd.NativeAdListener listener)Set events listener of an advertisement Must be called before NativeAd.load() voidsetMediaListener(@Nullable() NativeAd.NativeAdMediaListener mediaListener)Sets listener for media objects events, such as icon loading voidsetMediationEnabled(boolean mediationEnabled)Enables/disables mediation for current ad. voidsetNativeAdVideoListener(@Nullable() NativeAd.NativeAdVideoListener nativeAdVideoListener)Set events listener for native ad video Must be called before NativeAd.load() voidsetVideoQuality(int videoQuality)Desired video quality can be set. voidunregisterView()View de-registration. voiduseExoPlayer(boolean useExoPlayer)Enables/disables ExoPlayer (androidx.media's ExoPlayer) to play video. -
-
Constructor Detail
-
NativeAd
NativeAd(int slotId, Context context)
Public constructor- Parameters:
slotId- your slot idcontext- app context
-
NativeAd
NativeAd(int slotId, MenuFactory menuFactory, Context context)
Public constructor- Parameters:
slotId- your slot idmenuFactory- menuFactory for drawing adChoices optionscontext- app context
-
-
Method Detail
-
getAdChoicesListener
@Nullable() NativeAd.NativeAdChoicesListener getAdChoicesListener()
- Returns:
events listener of adChoices icon load Must be called before NativeAd.load()
-
getAdChoicesOptionListener
@Nullable() NativeAd.NativeAdChoicesOptionListener getAdChoicesOptionListener()
Returns listener for ad choice menu.
- Returns:
Object which implements NativeAdChoicesOptionListener interface.
-
getAdChoicesPlacement
int getAdChoicesPlacement()
Retrieve current position for AdChoices icon
- Returns:
Value is TOP_RIGHT, TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, MANUAL, or DRAWING_MANUAL
-
getAdSource
@Nullable() String getAdSource()
Get the name of source network. It always will be "myTarget" if no mediation enabled. returns null if ad is not loaded
- Returns:
ad source
-
getAdSourcePriority
float getAdSourcePriority()
Ad Source Priority is the value representing current ad network place in the queue of received advertisements. Works only with mediation. 0f if not loaded yet.
- Returns:
priority of ad source network
-
getBanner
@Nullable() NativePromoBanner getBanner()
Banner model for current ad. Null if not loaded
- Returns:
-
getCachePolicy
int getCachePolicy()
Retrieve current cachePolicy set previously
-
getHtml5ContentIsLoaded
boolean getHtml5ContentIsLoaded()
-
getListener
@Nullable() NativeAd.NativeAdListener getListener()
Get events listener of an advertisement
- Returns:
an instance of listener
-
getMediaListener
@Nullable() NativeAd.NativeAdMediaListener getMediaListener()
Gets listener for media objects events, such as icon loading
- Returns:
listener object
-
getNativeAdVideoListener
@Nullable() NativeAd.NativeAdVideoListener getNativeAdVideoListener()
Get events listener of an native ad video
- Returns:
an instance of listener
-
getNativeAdVideoPlayer
@Nullable() NativeAd.NativeAdVideoPlayer getNativeAdVideoPlayer()
- Returns:
interface for managing native ad player
-
getVideoQuality
int getVideoQuality()
Gets desired video quality of loading video. In vertical pixels.
- Returns:
video quality
-
handleAdChoicesClick
void handleAdChoicesClick(@NonNull() Context context)
Call to display adChoices options whose implementation has been passed using MenuFactory.
-
handleClick
void handleClick(boolean isCta, @NonNull() View view)
Call to trigger click on a view manually.
-
handleData
void handleData(@NonNull() String data)
Loads data for s2s partners
-
isMediationEnabled
boolean isMediationEnabled()
Get enable/disable mediation flag
- Returns:
flag
-
isUseExoPlayer
boolean isUseExoPlayer()
Gets current flag of using ExoPlayer (androidx.media's ExoPlayer) for video playing
- Returns:
param of using ExoPlayer
-
load
void load()
Start loading ads. In case of successful loading, the onLoad method will be called on the object passed as a listener, in case of loading error or if there is no advertisement to be shown - the onNoAd
Ad listener should be added before this call
-
loadFromBid
void loadFromBid(@NonNull() String bidId)
Start loading ad with the bidding ID
-
registerView
@Deprecated() void registerView(@NonNull() View view)
Registration of the Advertising view. Must be called before showing the ad
-
registerView
@Deprecated() void registerView(@NonNull() View view, @Nullable() List<View> clickableViews)
Registration of the Advertising view. Must be called before showing the ad
-
registerView
void registerView(@NonNull() NativeAdViewBinder nativeAdViewBinder)
Registration of the Advertising view via NativeAdViewBinder. Must be called before showing the ad
- Parameters:
nativeAdViewBinder- Advertising view binder
-
registerView
void registerView(@NonNull() NativeAdViewBinder nativeAdViewBinder, @Nullable() List<View> clickableViews)
Registration of the Advertising view via NativeAdViewBinder. Must be called before showing the ad
- Parameters:
nativeAdViewBinder- Advertising view binderclickableViews- specific clickable views inside Advertising view.
-
registerView
void registerView(@NonNull() NativeAdView nativeAdView)
Registration of the Advertising view. Must be called before showing the ad
-
registerView
void registerView(@NonNull() NativeAdView nativeAdView, @Nullable() List<View> clickableViews)
Registration of the Advertising view. Must be called before showing the ad
-
reloadHtmlContent
void reloadHtmlContent()
Reload Html5 content, if it exists and it was loaded before, nothing will happen otherwise.
-
setAdChoicesListener
void setAdChoicesListener(@Nullable() NativeAd.NativeAdChoicesListener adChoicesListener)
Set events listener of adChoices icon load Must be called before NativeAd.load()
-
setAdChoicesOptionListener
void setAdChoicesOptionListener(@Nullable() NativeAd.NativeAdChoicesOptionListener adChoicesOptionListener)
-
setAdChoicesPlacement
void setAdChoicesPlacement(int adChoicesPlacement)
Sets the place for AdChoices icon, by default used top-right position
- Parameters:
adChoicesPlacement- Value is TOP_RIGHT, TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, MANUAL, or DRAWING_MANUAL
-
setAdsLightPixelParams
void setAdsLightPixelParams(@NonNull() String adsLightType, @Nullable() Map<String, String> params)
Method for internal partners
-
setCachePolicy
void setCachePolicy(int cachePolicy)
By default, images and videos are preloaded. You can turn off the automatic loading of images and videos, but keep in mind that downloading them will take extra time, which will create an additional delay in displaying ads in your application.
-
setCollageItemsShowHandler
void setCollageItemsShowHandler(@Nullable() NativeAd.CollageItemsShowHandler collageItemsShowHandler)
Set collage items show handler Must be called before NativeAd.load()
-
setHtmlCustomEventListener
void setHtmlCustomEventListener(@Nullable() HtmlCustomEventListener listener)
Sets listener for HTML5 interactive in order to receive callbacks about custom events
- Parameters:
listener- - implementation of HtmlCustomEventListener
-
setHtmlInteractionListener
void setHtmlInteractionListener(@Nullable() HtmlInteractionListener listener)
Set user interaction listener for Html5 content. Must be called before NativeAd.load()
-
setHtmlInteractiveProgressListener
void setHtmlInteractiveProgressListener(@NonNull() HtmlInteractiveProgressListener listener)
Set progress listener for Html5 interactive progress. Must be called before NativeAd.load()
-
setHtmlLoadingListener
void setHtmlLoadingListener(@Nullable() HtmlLoadingListener listener)
Set loading listener for Html5 content. Must be called before NativeAd.load()
-
setHtmlLoadingTimeoutMillis
void setHtmlLoadingTimeoutMillis(long loadingTimeoutMillis)
Sets timeout for HTML5 content loading. If content was not loaded in provided interval, then
HtmlLoadingListener.onErrorwill be called. Must be called before NativeAd.load().- Parameters:
loadingTimeoutMillis- interval in millis, after which HTML5 content loading will be considered erroneous.
-
setInternalObject
void setInternalObject(@NonNull() Object internalObject)
Method for internal partners
-
setListener
void setListener(@Nullable() NativeAd.NativeAdListener listener)
Set events listener of an advertisement Must be called before NativeAd.load()
-
setMediaListener
void setMediaListener(@Nullable() NativeAd.NativeAdMediaListener mediaListener)
Sets listener for media objects events, such as icon loading
- Parameters:
mediaListener- listener object
-
setMediationEnabled
void setMediationEnabled(boolean mediationEnabled)
Enables/disables mediation for current ad. Default is true. Disabling this option may cause lower fill-rate
- Parameters:
mediationEnabled- if true - enable mediation, otherwise not
-
setNativeAdVideoListener
void setNativeAdVideoListener(@Nullable() NativeAd.NativeAdVideoListener nativeAdVideoListener)
Set events listener for native ad video Must be called before NativeAd.load()
-
setVideoQuality
void setVideoQuality(int videoQuality)
Desired video quality can be set. In vertical pixels. For example, if called
setVideoQuality(360)SDK will try to show video with nearest size, so if ad has ad video with 480x800 and 1920x1080 sizes, 480x800 will be used. Default is 360- Parameters:
videoQuality- desired quality in vertical pixels
-
unregisterView
void unregisterView()
View de-registration. Stops timers, frees resources. Must be called after view is no longer needed
-
useExoPlayer
void useExoPlayer(boolean useExoPlayer)
Enables/disables ExoPlayer (androidx.media's ExoPlayer) to play video. If exoplayer disabled, android default MediaPlayer will be used. Default is true, and it's recommended to not turn it off.
- Parameters:
useExoPlayer- flag to use ExoPlayer
-
-
-
-