BaseNativeAd

public abstract class BaseNativeAd extends Object

This is the base class for implementations of all native ad formats. When implementing a new native ad format, be sure to also implement and register an appropriate MoPubAdRenderer that supports the format.

Public Methods

public abstract void /clear(View view)

  • Description: The BaseNativeAd subclass should implement this method if the network requires the developer to reset or clear state of the native ad after it goes off screen and before it is rendered again. This method is optional.

  • Parameters:

    • view: The View containing the native ad whose state should be cleared.

public abstract void /destroy()

  • Description: The BaseNativeAd subclass should implement this method if the network requires the developer to destroy or cleanup their native ad when they are permanently finished with it. This method is optional.

  • Parameters: None.

protected final void /notifyAdClicked()

  • Description: The BaseNativeAd subclass should call this method to notify the MoPub SDK that the user has clicked the ad. This will cause the SDK to record an click for the ad. This method must be called when the native ad is clicked in order for the MoPub click trackers to fire correctly.

  • Parameters: None.

protected final void /notifyAdImpressed()

  • Description: The BaseNativeAd subclass should call this method to notify the MoPub SDK that the ad has been shown. This will cause the SDK to record an impression for the ad. This method must be called when the native ad is impressed in order for the MoPub impression trackers to fire correctly.

  • Parameters: None.

public abstract void /prepare(View view)

  • Description: The BaseNativeAd subclass should implement this method if the network requires the developer to prepare state for recording an impression or click before a view is rendered to screen. This method is optional.

  • Parameters:

    • view: The View containing the native ad to be prepared with impression and click trackers.

Last updated March 03, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)