Page tree


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.
See 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 AdRequest mAdRequest
protected com.pubmatic.sdk.common.RRFormatter mRRFormatter

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
void addCustomParameter(java.lang.string customParamName, java.lang.string value) Allows setting of extra custom parameters to ad request.
void addCustomParametersMap(java.util.HashMap<java.lang.string,java.lang.string> customParamMap) Convenience method to add all custom parameters in one Map.
void destroy()
java.util.Map<java.lang.string,java.lang.string> getAdRequestParameters() Collection of ad request parameters.
java.lang.string getAdResponse() Returns the native ad response in json format.
java.lang.string getClick() Get the landing url whenever user clicks on the Native Ad
java.lang.string getJsTracker() Get the javascript tracker received in native response.
android.location.Location getLocation()
java.util.List<PMNativeAssetResponse> getNativeAssets() Get the list of native assets.
Boolean getUseInternalBrowser() Returns the currently configured internal browser setting.
Boolean isTest() Access for test mode state of the instance.
void loadImage(android.widget.ImageView imageView, java.lang.string url) Use this method to load your resource images.
void loadRequest(AdRequest adrequest)
void reset()
void resetClickListener(Boolean state) Publisher
protected void setAdrequest(AdRequest adRequest)
void setAdRequest(AdRequest adRequest)
void setRequestListener(PMNativeAd.NativeRequestListener requestListener)
void setTest(Boolean test) Sets the instance test mode.
void setUseInternalBrowser(Boolean useInternalBrowser) Controls use of the internal browser.
void trackViewForInteractions(android.view.View view) Call this method whenever your view is ready to display.
void update()

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)


⇧ Top