MoPubView

public class MoPubView

An object that represents a MoPub banner ad.

Public Constants

public static int /MoPubAdSize.MATCH_VIEW_INT

  • Description: Constant that specifies the desired height for an ad to match that of the host view.

public static int /MoPubAdSize.HEIGHT_50_INT

  • Description: Constant that specifies the desired height for an ad to be 50.

public static int /MoPubAdSize.HEIGHT_90_INT

  • Description: Constant that specifies the desired height for an ad to be 90.

public static int /MoPubAdSize.HEIGHT_250_INT

  • Description: Constant that specifies the desired height for an ad to be 250.

public static int /MoPubAdSize.HEIGHT_280_INT

  • Description: Constant that specifies the desired height for an ad to be 280.

Public Methods

public void /destroy()

  • Description: Remove existing banner instance in session. Used when finished showing an ad to free up existing resources.

  • Parameters: None.

public void /forceRefresh()

  • Description: Manually sends out a new ad request that is initiated by the publisher. Used to issue a new ad request and start a new refresh cycle.

  • Parameters: None.

public AdFormat /getAdFormat()

  • Description: Always returns the String ‘banner’. Only called after an ad request.

  • Parameters: None.

public int /getAdHeight()

  • Description: Returns the height of the creative in the ad response sent from the MoPub ad server.

  • Parameters: None.

public MoPubAdSize /getAdSize()

  • Description: Returns the height of the creative that the publisher is requesting. Refer to MoPubView.MoPubAdSize for a list of predefined ad size constants.

  • Parameters: None.

public String /getAdUnitId()

  • Description: Returns the MoPub ad unit ID String specified in the ad request.

  • Parameters: None.

public int /getAdWidth()

  • Description: Returns the width of the creative in the ad response sent from the MoPub ad server.

  • Parameters: None.

public boolean /getAutorefreshEnabled()

  • Description: Returns whether auto refresh is enabled. Auto refresh makes a new ad request based on a time interval. Returns true if the ad will attempt to refresh automatically; false otherwise.

  • Parameters: None.

public BannerAdListener /getBannerAdListener()

  • Description: Returns a BannerAdListener instance (the ad listener associated with the current banner ad object).

  • Parameters: None.

public String /getClickTrackingUrl()

  • Deprecated.

public String /getKeywords()

  • Description: Returns any non-user-identifiable keywords set on the current banner object. Null if no keywords have been set.

  • Parameters: None.

public Map<String,Object> /getLocalExtras()

  • Description: Returns a map of key-value pairs set on the current banner object to be used later. Null if no local extras are set.

  • Parameters: None.

public Location /getLocation()

  • Description: Returns a location object that set on the current banner object. Null if no location has been set.

  • Parameters: None.

public String /getResponseString()

  • Deprecated.

public String /getUserDataKeywords()

  • Description: Returns any user-identifiable keywords set on the current banner object. Returns user-identifiable keywords, if available; if none have been set, returns null.

  • Parameters: None.

public void /loadAd()

  • Description: Issues an ad request to the MoPub ad server. This method should only be called after initializing the SDK via initializeSdk().

  • Parameters: None.

public void /loadAd(MoPubAdSize moPubAdSize)

  • Description: Issues an ad request with the specified ad size. This method should only be called after initializing the SDK via initializeSdk(). Refer to our banner ad instructions for additional usage directions.

  • Parameters:

    • moPubAdSize: A list of enums representing recognized banner ad sizes.

public void /setAdSize(MoPubAdSize moPubAdSize)

  • Description: Passes in a specific ad size to request for the current banner ad.

  • Parameters:

public void /setAdUnitId(String adUnitId)

  • Description: Sets the ad unit ID on the current banner ad object to be used in the ad request. Must not be null.

  • Parameters:

    • adUnitId: MoPub ad unit ID String.

public void /setAutorefreshEnabled(boolean enabled)

  • Description: Specifies whether the current banner ad should automatically refresh.

  • Parameters:

    • enabled: ‘true’ to automatically refresh; ‘false’ otherwise.

public void /setBannerAdListener(BannerAdListener listener)

  • Description: Registers a listener for the current ad object to be informed of the ad’s lifecycle events.

  • Parameters:

    • listener: An object contains listeners corresponding to the banner’s lifecycle events.

public void /setKeywords(String keywords)

  • Description: Optional. Specifies non-user-identifiable keywords on the current banner object to pass in the ad request for ad targeting.

  • Parameters:

    • keywords: A String containing data to be passed to the current banner ad object.

public void /setLocalExtras(Map<String,Object> localExtras)

  • Description: Specifies a map of key-value pairs on the current banner object to be passed in the ad request for ad targeting. Use this to append additional data for mediation.

  • Parameters:

public void /setLocation(Location location)

  • Description: Specifies a location object on the current banner object to be passed in the ad request for ad targeting.

  • Parameters:

    • location: A Location object. Null if not available, in which case it is not passed to the ad request URL.

public void /setTimeout(int milliseconds)

  • Deprecated as of release 4.4.0.

public void /setUserDataKeywords(String userDataKeywords)

  • Description: In GDPR-applicable cases, specifies user-identifiable keywords on the current banner object to be passed in the ad request for targeting.

  • Parameters:

    • userDataKeywords: A String containing user-identifiable data to be passed to the current banner ad object.

Last updated March 04, 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.)