PMNativeAd

Document created by david.simerly on Nov 21, 2017Last modified by david.simerly on Apr 4, 2018
Version 2Show Document
  • View in full screen mode

PubMatic SDKs

AdRequest

NativeAdSize

PMAdRendered

PMAdRequest

PMAdRequest.AD_TYPE

PMAdRequest.AWT_OPTION

PMAdRequest.ETHNICITY

PMAdRequest.GENDER

PMAdRequest.HASHING_TECHNIQUE

PMAdRequest.OPERID

PMAdRequest.RS

PMAdSize

PMAdSize

PMBannerAdRequest

PMBannerAdView

PMBannerAdView.BannerAdViewDelegate

PMBannerAdView.BannerAdViewDelegate.
     ActivityListener

PMBannerAdView.BannerAdViewDelegate.
     FeatureSupportHandler

PMBannerAdView.BannerAdViewDelegate.
     InternalBrowserListener

PMBannerAdView.BannerAdViewDelegate.
     RequestListener

PMBannerAdView.BannerAdViewDelegate.
     RichMediaListener

PMBannerImpression

PMBid

PMError

PMImpression

PMInterstitialAd

PMInterstitialAd.InterstitialAdListener

PMInterstitialAd.InterstitialAdListener.
     ActivityListener

PMInterstitialAd.InterstitialAdListener.
     FeatureSupportHandler

PMInterstitialAd.InterstitialAdListener.
     InternalBrowserListener

PMInterstitialAd.InterstitialAdListener.
     RequestListener

PMInterstitialAd.InterstitialAdListener.
     RichMediaListener

PMInterstitialAdRequest

PMLogger

PMLogger.LogListener

PMLogger.PMLogLevel

➤ PMNativeAd

PMNativeAd.Image

PMNativeAd.NativeRequestListener

PMNativeAdRequest

PMNativeAssetRequest

PMNativeAssetResponse

PMNativeDataAssetRequest

PMNativeDataAssetResponse

PMNativeDataAssetTypes

PMNativeImageAssetRequest

PMNativeImageAssetResponse

PMNativeImageAssetTypes

PMNativeTitleAssetRequest

PMNativeTitleAssetResponse

PMPrefetchManager

PMPrefetchManager.PMPrefetchListener

PMPrefetchRequest

PubMaticSDK


PubMatic Android SDK Guide

com.pubmatic.sdk.nativead

Class PMNativeAd

java.lang.Object
    com.pubmatic.sdk.nativead.PMNativeAd

public final class PMNativeAd
extends java.lang.Object

 

Main class used for requesting native ads.
Refer Sample application for example of implementation.

 

Nested Class Summary

Modifier and TypeClass and Description
static class PMNativeAd.Image 
static interface PMNativeAd.NativeRequestListener An interface to notify the native ad request callbacks

 

Field Summary

Modifier and TypeField and Description
protected AdRequestmAdRequest 
protected com.pubmatic.sdk.common.RRFormattermRRFormatter 

 

Constructor Summary

Constructor and Description
PMNativeAd(android.content.Context context) 

 

Method Summary

Modifier and TypeMethod and Description
voidaddCustomParameter(java.lang.string customParamName, java.lang.string value) Allows setting of extra custom parameters to ad request.
voidaddCustomParametersMap(java.util.HashMap<java.lang.string,java.lang.string> customParamMap) Convenience method to add all custom parameters in one Map.
voiddestroy() 
java.util.Map<java.lang.string,java.lang.string>getAdRequestParameters() Collection of ad request parameters.
java.lang.stringgetAdResponse() Returns the native ad response in json format.
java.lang.stringgetClick() Get the landing url whenever user clicks on the Native Ad
java.lang.stringgetJsTracker() Get the javascript tracker received in native response.
android.location.LocationgetLocation() 
java.util.List<PMNativeAssetResponse>getNativeAssets() Get the list of native assets.
BooleangetUseInternalBrowser() Returns the currently configured internal browser setting.
BooleanisTest() Access for test mode state of the instance.
voidloadImage(android.widget.ImageView imageView, java.lang.string url) Use this method to load your resource images.
voidloadRequest(AdRequest adrequest) 
voidreset() 
voidresetClickListener(Boolean state) Publisher
protected voidsetAdrequest(AdRequest adRequest) 
voidsetAdRequest(AdRequest adRequest) 
voidsetRequestListener(PMNativeAd.NativeRequestListener requestListener) 
voidsetTest(Boolean test) Sets the instance test mode.
voidsetUseInternalBrowser(Boolean useInternalBrowser) Controls use of the internal browser.
voidtrackViewForInteractions(android.view.View view) Call this method whenever your view is ready to display.
voidupdate() 

 

Methods inherited from class java.lang.Object


clone, equals, finalize, getClass, hashCode, notify, notifyAll, tostring, wait, wait, wait

 

Field Detail


mAdRequest

protected AdRequest mAdRequest

 

mRRFormatter

protected com.pubmatic.sdk.common.RRFormatter mRRFormatter

 

Constructor Detail


PMNativeAd

public PMNativeAd(android.content.Context context)

 

 

Parameters:
context -

 

Method Detail


 

setAdrequest

protected void setAdrequest(AdRequest adRequest)

 

setTest

public void setTest(Boolean test)

 

Sets the instance test mode. If set to test mode the instance will request test ads for the configured zone.

 

Warning: This should never be enabled for application releases.

 

 

Parameters:
test - true to set test mode, false to disable test mode.

 

isTest

public Boolean isTest()

 

Access for test mode state of the instance.

 

Returns:
true if the instance is set to test mode, false if test mode is disabled.

 

setRequestListener

public void setRequestListener(PMNativeAd.NativeRequestListener requestListener)

 

getAdRequestParameters

public java.util.Map<java.lang.string,java.lang.string> getAdRequestParameters()

 

Collection of ad request parameters. Allows setting extra network parameters.

 

The SDK will set various parameters based on configuration and other options.

 

 

Returns:
Map containing optional request parameters.

 

addCustomParameter

public void addCustomParameter(java.lang.string customParamName, java.lang.string value)

 

Allows setting of extra custom parameters to ad request. Add custom parameter (key-value).

 

addCustomParametersMap

public void addCustomParametersMap(java.util.HashMap<java.lang.string,java.lang.string> customParamMap)

 

Convenience method to add all custom parameters in one Map. Allows setting of extra custom parameters to ad request.

 

Parameters:
customParamMap - Map containing custom parameters

 

loadImage

public void loadImage(android.widget.ImageView imageView, java.lang.string url)

 

Use this method to load your resource images.

 

Parameters:
imageView -
url -

 

loadRequest

public void loadRequest(AdRequest adrequest)

 

 

Parameters:
adrequest -

 

update

public void update()

 

resetClickListener

public void resetClickListener(Boolean state)

 

Publisher

 

Parameters:
state -

 

trackViewForInteractions

public void trackViewForInteractions(android.view.View view)

 

Call this method whenever your view is ready to display. Calling this method will fire the Ad display tracker and count impression.

 

You must call this whenever the view is visible.

 

 

Parameters:
view - top level view which displays the native ads i.e. container for the native ad

 

getLocation

public android.location.Location getLocation()

 

reset

public void reset()

 

destroy

public void destroy()

 

getNativeAssets

public java.util.List<PMNativeAssetResponse> getNativeAssets()

 

Get the list of native assets.

 

Returns:
List of if response contains any assets else returns null

 

getJsTracker

public java.lang.string getJsTracker()

 

Get the javascript tracker received in native response.
The javascript tracker is represented by 'jstracker' object in OpenRTB Native ad specification.

 

Note: If jstracker is present, publisher should execute this javascript at impression time (after onNativeAdReceived callback) whenever possible.

 

 

Returns:
JsTracker as string if present, else returns null.

 

getClick

public java.lang.string getClick()

 

Get the landing url whenever user clicks on the Native Ad

 

Returns:
landing page url

 

getAdResponse

public java.lang.string getAdResponse()

 

Returns the native ad response in json format.

 

Returns:

 

setUseInternalBrowser

public void setUseInternalBrowser(Boolean useInternalBrowser)

 

Controls use of the internal browser. If used, a dialog will be used to show a browser in the application for ads that are clicked on (that open URLs). If not used an intent is started to invoke the system browser (or whatever is configured to handle the intent).

 

Parameters:
useInternalBrowser - true to use the internal browser, false to not use the internal browser.

 

getUseInternalBrowser

public Boolean getUseInternalBrowser()

 

Returns the currently configured internal browser setting.

 

Returns:
true if using the internal browser, false if not using the internal browser.

 

setAdRequest

public void setAdRequest(AdRequest adRequest)

 

Attachments

    Outcomes