Android Verizon Ads SDK Standard Edition Documentation  1.14
Classes | Public Member Functions | List of all members
NativeAd Class Reference

NativeAd is a placement used for ads that are a collection of assets that can be individually laid out in a way that looks and feels like the application. More...

Classes

interface  NativeAdListener
 Interface for receiving notifications from the NativeAd. More...
 

Public Member Functions

void destroy ()
 Destroys the NativeAd and frees all associated resources. More...
 
String getAdType ()
 Returns a string object for the NativeAd’s type. More...
 
Component getComponent (final Context context, final String componentId)
 Returns a Component instance for the native component with specified ID if it exists on this NativeAd instance. More...
 
Component getComponent (final String componentId)
 Returns a Component instance for the native component with specified ID if it exists on this NativeAd instance. More...
 
Set< StringgetComponentIds ()
 Gets a set of strings representing the components of the NativeAd. More...
 
CreativeInfo getCreativeInfo ()
 Gets a CreativeInfo object containing identifiers for the NativeAd’s creative and its demand source, if available. More...
 
JSONObject getJSON ()
 Returns a sanitized copy of the native ad JSON for the current component and its descendants that can be queried for things like ad properties and metadata. More...
 
JSONObject getJSON (final String componentId)
 Returns a sanitized copy of the native ad JSON for the specified child component and its descendants that can be queried for things like ad properties and metadata. More...
 
String getPlacementId ()
 Get the placementId for the NativeAd. More...
 
void invokeDefaultAction (final Context context)
 Performs the default action for the ad. More...
 
boolean registerContainerView (final ViewGroup containerView)
 Register a view for tracking impressions. More...
 

Detailed Description

NativeAd is a placement used for ads that are a collection of assets that can be individually laid out in a way that looks and feels like the application.

Member Function Documentation

◆ destroy()

void destroy ( )

Destroys the NativeAd and frees all associated resources.

Any views that are part of this ad will be removed from the view hierarchy. After the ad has been destroyed, the NativeAd instance is no longer usable. This method must be called on the UI thread.

◆ getAdType()

String getAdType ( )

Returns a string object for the NativeAd’s type.

This method must be called on the UI thread.

Returns
the ad type

◆ getComponent() [1/2]

Component getComponent ( final Context  context,
final String  componentId 
)

Returns a Component instance for the native component with specified ID if it exists on this NativeAd instance.

A null is returned if this method is called off the main thread, the ad has expired or the component does not exist. This method is deprecated. Please use NativeAd#getComponent(String) instead.

Parameters
contextan Activity context
componentIdthe id of the component being requested
Returns
the Component instance or null

◆ getComponent() [2/2]

Component getComponent ( final String  componentId)

Returns a Component instance for the native component with specified ID if it exists on this NativeAd instance.

A null is returned if this method is called off the main thread, the ad has expired or the component does not exist.

Parameters
componentIdthe id of the component being requested
Returns
the Component instance or null

◆ getComponentIds()

Set<String> getComponentIds ( )

Gets a set of strings representing the components of the NativeAd.

Returns
the set of components, if available; otherwise an empty set

◆ getCreativeInfo()

CreativeInfo getCreativeInfo ( )

Gets a CreativeInfo object containing identifiers for the NativeAd’s creative and its demand source, if available.

This method must be called on the UI thread.

Returns
the CreativeInfo object for the ad, if available; otherwise null

◆ getJSON() [1/2]

JSONObject getJSON ( )

Returns a sanitized copy of the native ad JSON for the current component and its descendants that can be queried for things like ad properties and metadata.

Returns
a copy of the JSON for the current component

◆ getJSON() [2/2]

JSONObject getJSON ( final String  componentId)

Returns a sanitized copy of the native ad JSON for the specified child component and its descendants that can be queried for things like ad properties and metadata.

Returns null if the component is not available.

Parameters
componentIdthe NativeAd component that should be returned
Returns
a copy of the JSON for the component, if available; otherwise null

◆ getPlacementId()

String getPlacementId ( )

Get the placementId for the NativeAd.

This method must be called on the UI thread.

Returns
the placementId for the NativeAd, or null if the ad has been destroyed.

◆ invokeDefaultAction()

void invokeDefaultAction ( final Context  context)

Performs the default action for the ad.

This method should be called when the user interacts with an ad in a manner that is not captured by the built in click listeners, and the publisher intends for the interaction to represent ad interaction. Examples of non typical ad interaction captured by the publisher would be a user gesture, voice trigger or other uncaptured behavior. This method must be called on the UI thread.

Parameters
contextthe context for performing the action

◆ registerContainerView()

boolean registerContainerView ( final ViewGroup  containerView)

Register a view for tracking impressions.

This call is required. This view should contain all required component views for the native ad. This method must be called on the main thread.

Parameters
containerViewThe view containing the native ad's component views.
Returns
true if the Open Measurement SDK started tracking the containerView successfully; otherwise, false.