Skip to end of metadata
Go to start of metadata

JavaScript is disabled on your browser.
com.appnexus.opensdk

Class NativeAdRequest

  • java.lang.Object
    • com.appnexus.opensdk.NativeAdRequest


  • public class NativeAdRequest
    extends java.lang.Object
    Define the attributes used for requesting a native ad.
    • Constructor Detail

      • NativeAdRequest

        public NativeAdRequest(android.content.Context context,
                               java.lang.String placementID)
      • NativeAdRequest

        public NativeAdRequest(android.content.Context context,
                               java.lang.String inventoryCode,
                               int memberID)
    • Method Detail

      • getOpensNativeBrowser

        public boolean getOpensNativeBrowser()
        Deprecated. Use getClickThroughAction instead Refer ANClickThroughAction
        Retrieve the setting that determines whether or not the device's native browser is used instead of the in-app browser when the user clicks an ad.
        Returns:
        true if the device's native browser will be used; false otherwise.
      • setOpensNativeBrowser

        public void setOpensNativeBrowser(boolean opensNativeBrowser)
        Deprecated. Use setClickThroughAction instead Refer ANClickThroughAction
        Set this to true to disable the in-app browser. This will cause URLs to open in a native browser such as Chrome so that when the user clicks on an ad, your app will be paused and the native browser will open. Set this to false to enable the in-app browser instead (a lightweight browser that runs within your app). The default value is false.
        Parameters:
        opensNativeBrowser - (boolean)
      • setPlacementID

        public void setPlacementID(java.lang.String placementID)
        Sets the placement id of the NativeAdRequest. The placement ID identifies the location in your application where ads will be shown. You must have a valid, active placement ID to monetize your application.
        Parameters:
        placementID - The placement ID to use.
      • setLoadsInBackground

        public void setLoadsInBackground(boolean doesLoadingInBackground)
        Sets whether or not to load landing pages in the background before displaying them. This feature is on by default, but only works with the in-app browser (which is also enabled by default). Disabling this feature may cause redirects, such as to the app store, to first open a blank web page.
        Parameters:
        doesLoadingInBackground - Whether or not to load landing pages in background.
      • getLoadsInBackground

        public boolean getLoadsInBackground()
        Gets whether or not this AdView will load landing pages in the background before displaying them. This feature is on by default, but only works with the in-app browser (which is also enabled by default). Disabling this feature may cause redirects, such as to the app store, to first open a blank web page.
        Returns:
        Whether or not redirects and landing pages are loaded/processed in the background before being displayed.
      • setClickThroughAction

        public void setClickThroughAction(ANClickThroughAction clickThroughAction)
        Determines what action to take when the user clicks on an ad. If set to ANClickThroughAction.OPEN_DEVICE_BROWSER/ANClickThroughAction.OPEN_SDK_BROWSER then, NativeAdEventListener.onAdWasClicked() will be triggered and corresponding browser will load the click url. If set to ANClickThroughAction.RETURN_URL then, NativeAdEventListener.onAdWasClicked(String clickUrl,String fallbackURL) will be triggered with clickUrl and clickFallbackURL as its argument. It is ASSUMED that the App will handle it appropriately.
        Parameters:
        clickThroughAction - ANClickThroughAction.OPEN_SDK_BROWSER which is default or ANClickThroughAction.OPEN_DEVICE_BROWSER or ANClickThroughAction.RETURN_URL
      • getPlacementID

        public java.lang.String getPlacementID()
        Retrieve the placement id for ad request.
        Returns:
        The Placement ID
      • getExternalUid

        public java.lang.String getExternalUid()
        Retrieve the externalUID that was previously set.
        Returns:
        externalUID.
      • setExternalUid

        public void setExternalUid(java.lang.String externalUid)
        Set the current user's externalUID
        Parameters:
        externalUid - .
      • setInventoryCodeAndMemberID

        public void setInventoryCodeAndMemberID(int memberID,
                                                java.lang.String inventoryCode)
        Sets the inventory code and member id of this native ad request. The inventory code provides a more human readable way to identify the location in your application where ads will be shown. Member id is required to for using this feature. If both inventory code and placement id are presented, inventory code will be used instead of placement id on the ad request.
        Parameters:
        memberID - The member id that this native ad belongs to.
        inventoryCode - The inventory code of this native ad.
      • getMemberID

        public int getMemberID()
        Retrieve the member ID.
        Returns:
        the member id that this AdView belongs to.
      • getInventoryCode

        public java.lang.String getInventoryCode()
        Retrieve the inventory code.
        Returns:
        the current inventory code.
      • setGender

        public void setGender(AdView.GENDER gender)
        Set user's gender for targeting
        Parameters:
        gender - User's gender
      • getGender

        public AdView.GENDER getGender()
        Get the user's gender
        Returns:
        User's gender
      • setAge

        public void setAge(java.lang.String age)
        Set the age or age range of the user
        Parameters:
        age - User's age or age range
      • getAge

        public java.lang.String getAge()
        Get the age or age range for the ad request
        Returns:
        age
      • addCustomKeywords

        public void addCustomKeywords(java.lang.String key,
                                      java.lang.String value)
        Add a custom keyword to the request URL for the ad. This is used to set custom targeting parameters within the AppNexus platform. You will be given the keys and values to use by your AppNexus account representative or your ad network.
        Parameters:
        key - The key to add; this cannot be null or empty.
        value - The value to add; this cannot be null or empty.
      • removeCustomKeyword

        public void removeCustomKeyword(java.lang.String key)
        Remove a custom keyword from the request URL for the ad. Use this to remove a keyword previously set using addCustomKeywords.
        Parameters:
        key - The key to remove; this cannot be null or empty.
      • clearCustomKeywords

        public void clearCustomKeywords()
        Clear all custom keywords from the request URL.
      • shouldLoadImage

        public void shouldLoadImage(boolean flag)
        Call to override the image resource auto download feature. If True (the default value) the SDK will automatically download the Image resource and the onAdLoaded will only be called after the resource has been downloaded. If you return False the Image will not automatically load but you can download the image manually be retrieving the URL of the image using getImageUrl() in NativeAdResponse
      • shouldLoadIcon

        public void shouldLoadIcon(boolean flag)
        Call to override the icon resource auto download feature. If True (the default value) the SDK will automatically download the Icon image resource and the onAdLoaded will only be called after the resource has been downloaded. If you return False the Image will not automatically load but you can download the icon image manually be retrieving the URL of the image using getIconUrl() in NativeAdResponse
      • setListener

        public void setListener(NativeAdRequestListener listener)
        Register a listener for ad success/fail to load notification events
        Parameters:
        listener - The RequestListener to register
      • getListener

        public NativeAdRequestListener getListener()
        Set the listener that listens the state of the request
        Returns:
        The registered request listener
      • getRequestParameters

        public com.appnexus.opensdk.ut.UTRequestParameters getRequestParameters()
        Provide the request parameters of this ad
        Returns:
        UTRequestParameters
      • getMediaType

        public com.appnexus.opensdk.MediaType getMediaType()
        Media type can be Banner, Interstitial or Native
        Returns:
        the media type of this ad
      • isReadyToStart

        public boolean isReadyToStart()
        Checks whether an ad is ready to load a new one
        Returns:
        true if settings are ready to load a new ad
      • loadAd

        public boolean loadAd()
        Call this to request a native ad for parameters described by this object.
        Returns:
        true if ad request is scheduled successfully
      • getAdDispatcher

        public com.appnexus.opensdk.AdDispatcher getAdDispatcher()
        Provide the ad dispatcher of this ad
        Returns:
        ad dispatcher

  • No labels