public final class

InMobiNative

extends Object
java.lang.Object
   ↳ com.inmobi.ads.InMobiNative

Class Overview

Use this class to integrate native ads.

Note This class is not thread-safe. All methods on instances of this class must be called on the UI thread.

Summary

Nested Classes
class InMobiNative.Downloader This is an API used to control the download the APK into the app and also show the progress while downloading  
interface InMobiNative.LockScreenListener A listener for receiving Lockscreen events during the lifecycle of a Native ad. 
interface InMobiNative.NativeAdListener A listener for receiving notifications during the lifecycle of a Native ad. 
interface InMobiNative.NativeAdRequestListener A listener to notify the outcome of a prefetch ad request. 
Public Constructors
InMobiNative(Context context, long placementId, InMobiNative.NativeAdListener listener)
Creates an instance of InMobiNative.
InMobiNative(Context context, long placementId, NativeAdEventListener listener)
Creates an instance of InMobiNative.
Public Methods
void destroy()
Destroy the Native ad view.
float getAdBid()
Returns bid info about Ad if console open bid info available otherwise returns 0
String getAdCtaText()
String getAdDescription()
String getAdIconUrl()
String getAdLandingPageUrl()
JSONObject getAdMetaInfo()
Returns meta info about Ad if any such info is available otherwise returns empty JSONObject
float getAdRating()
String getAdTitle()
int getBidSharing()
Returns bid sharing type about Ad if console open bid info available otherwise returns 0 (first_price)
String getCreativeId()
Returns creativeId if the Native ad was loaded successfully and creativeId is available otherwise returns empty string.
JSONObject getCustomAdContent()
InMobiNative.Downloader getDownloader()
View getPrimaryViewOfWidth(View convertView, ViewGroup parent, int viewWidthInPixels)
View getPrimaryViewOfWidth(Context context, View convertView, ViewGroup parent, int viewWidthInPixels)
Method to return a native ad view.
View getPrimaryViewOfWidthAndHeight(Context context, View convertView, ViewGroup parent, int viewWidthInPixels, int viewHeightInPixels)
void getSignals()
Called to create the request payload & the value is returned in onRequestPayloadCreated(byte[]) callback on success, and in case of failure onRequestPayloadCreationFailed(InMobiAdRequestStatus) is invoked.
boolean isAppDownload()
boolean isReady()
Returns true if the native was loaded successfully and is ready to be shown.
Boolean isVideo()
This api provides information if the ad returned contains a video or not.
void load(Context context)
Submit a request to load ad content.
void load()
Submit a request to load Native ad.
void load(byte[] response)
Called to render the ad with the provided response.
final void pause()
Pauses any extra processing associated with this InMobiNative ad.
void reportAdClickAndOpenLandingPage()
static void requestAd(Context context, InMobiAdRequest adRequest, InMobiNative.NativeAdRequestListener listener)
Request for a native ad.
final void resume()
Resumes an InMobiNative ad after a previous call to pause().
void setDownloaderEnabled(boolean downloaderEnabled)
Method to enable/disable the downloader.
void setExtras(Map<String, String> extras)
Set any additional custom parameters that will be sent in the ad request.
void setKeywords(String keywords)
Set comma delimited keywords for targeting purpose
void setListener(NativeAdEventListener listener)
Method to update the pub listener
void setNativeAdListener(InMobiNative.NativeAdListener listener)
Method to update the pub listener.
void setSecondPrice(float secondPrice)
Method to get pub's second price back for sdk
void setVideoEventListener(VideoEventListener listener)
Method to add or update the video events listener for pub
void showOnLockScreen(InMobiNative.LockScreenListener lockScreenListener)
Call this method to inform SDK that this Ad will be shown on LockScreen.
void takeAction()
Call this method to take action which is caused by any user interaction with ad view on Lockscreen.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public InMobiNative (Context context, long placementId, InMobiNative.NativeAdListener listener)

Creates an instance of InMobiNative.

Parameters
context Provide the current context instance

public InMobiNative (Context context, long placementId, NativeAdEventListener listener)

Creates an instance of InMobiNative.

Parameters
context Provide the current context instance
placementId The placementId for which the object is created
listener Listener to get lifecycle callbacks

Public Methods

public void destroy ()

Destroy the Native ad view.

Note This method must be called on the UI thread. Failure to do so will affect your ability to monetize with the InMobi Ad SDK.

public float getAdBid ()

Returns bid info about Ad if console open bid info available otherwise returns 0

Returns
  • float

public String getAdCtaText ()

public String getAdDescription ()

public String getAdIconUrl ()

public String getAdLandingPageUrl ()

public JSONObject getAdMetaInfo ()

Returns meta info about Ad if any such info is available otherwise returns empty JSONObject

Returns
  • JSONObject

public float getAdRating ()

public String getAdTitle ()

public int getBidSharing ()

Returns bid sharing type about Ad if console open bid info available otherwise returns 0 (first_price)

Returns
  • float

public String getCreativeId ()

Returns creativeId if the Native ad was loaded successfully and creativeId is available otherwise returns empty string.

Returns
  • String

public JSONObject getCustomAdContent ()

public InMobiNative.Downloader getDownloader ()

public View getPrimaryViewOfWidth (View convertView, ViewGroup parent, int viewWidthInPixels)

Parameters
convertView Recycled view provided by the Adapter.
parent The parent for the primary view
Returns
  • a native ad view that is constructed by InMobi if ad load was successful, null otherwise.

public View getPrimaryViewOfWidth (Context context, View convertView, ViewGroup parent, int viewWidthInPixels)

Method to return a native ad view. This method should be called only when the onAdLoadSucceeded(InMobiNative) callback was provided.

Parameters
context Context in which ad will be rendered.
convertView Recycled view provided by the Adapter.
parent The parent for the primary view
Returns
  • a native ad view that is constructed by InMobi if ad load was successful, null otherwise.

public View getPrimaryViewOfWidthAndHeight (Context context, View convertView, ViewGroup parent, int viewWidthInPixels, int viewHeightInPixels)

Parameters
context Context in which ad will be rendered.
convertView Recycled view provided by the Adapter.
parent The parent for the primary view
viewWidthInPixels parent view width
viewHeightInPixels parent view height
Returns
  • a native ad view that is constructed by InMobi if ad load was successful, null otherwise, this ad size can be set specifically.

public void getSignals ()

Called to create the request payload & the value is returned in onRequestPayloadCreated(byte[]) callback on success, and in case of failure onRequestPayloadCreationFailed(InMobiAdRequestStatus) is invoked.

public boolean isAppDownload ()

public boolean isReady ()

Returns true if the native was loaded successfully and is ready to be shown.

public Boolean isVideo ()

This api provides information if the ad returned contains a video or not. It returns true if the ad contains a video and returns false vice versa. It will return null if this method is called in a wrong state, i.e., can be called only after the onAdLoadSucceeded(InMobiNative) callback is given.

Returns
  • a Boolean if the ad returned contains a video or not

public void load (Context context)

Submit a request to load ad content. Use this method in conjunction with the requestAd(Context, InMobiAdRequest, NativeAdRequestListener) method to load the prefetched ad when the monetization event is imminent.

Parameters
context the Context where the ad will be rendered.

public void load ()

Submit a request to load Native ad. This method returns immediately upon enqueuing a request. Client code will be notified of the result on the InMobiNative.NativeAdListener callback that it supplied while instantiating an InMobiNative object.

Note This method must be called on the UI thread. Failure to do so will affect your ability to monetize with the InMobi Ad SDK.

public void load (byte[] response)

Called to render the ad with the provided response. Once the SDK starts loading the provided response, it will start giving callbacks through NativeAdEventListener listener.

Parameters
response Represents the response to be used to render an ad

public final void pause ()

Pauses any extra processing associated with this InMobiNative ad. Your app must call this method in the onPause method of the containing activity or fragment.

While using InMobiNative with the following constructor InMobiNative(Context, long, NativeAdEventListener)}, or using load(Context) where context as activity there is no need to call pause().

public void reportAdClickAndOpenLandingPage ()

public static void requestAd (Context context, InMobiAdRequest adRequest, InMobiNative.NativeAdRequestListener listener)

Request for a native ad. Use this method to prefetch native ads in your application. This method returns immediately after submitting a request. You will be notified via the InMobiNative.NativeAdRequestListener implementation that you supply in this call when the ad request completes.

Note: This method keeps a weak reference to the InMobiNative.NativeAdRequestListener instance and will be garbage collected if you do not keep a strong reference to it. To receive callbacks when an request is completed caller should keep strong reference of InMobiNative.NativeAdRequestListener.

Note This method must be called on the UI thread. Failure to do so will affect your ability to monetize with the InMobi Ad SDK.

Parameters
context any Context implementation
adRequest an InMobiAdRequest to help customize the ad request
listener an InMobiNative.NativeAdRequestListener implementation that will be called when the ad request completes

public final void resume ()

Resumes an InMobiNative ad after a previous call to pause(). Your app must call this method in the onResume method of the containing activity or fragment.

While using InMobiNative with the following constructor InMobiNative(Context, long, NativeAdEventListener)},or using load(Context) where context as activity there is no need to call resume()}.

public void setDownloaderEnabled (boolean downloaderEnabled)

Method to enable/disable the downloader. If disabled, then the SDK won't download the APK on it's own.

Parameters
downloaderEnabled Represents whether the downloader is enabled or not.

public void setExtras (Map<String, String> extras)

Set any additional custom parameters that will be sent in the ad request.

public void setKeywords (String keywords)

Set comma delimited keywords for targeting purpose

public void setListener (NativeAdEventListener listener)

Method to update the pub listener

Parameters
listener Represents the new listener

public void setNativeAdListener (InMobiNative.NativeAdListener listener)

Method to update the pub listener. Use setListener(NativeAdEventListener) instead.

Parameters
listener Represents the new listener

public void setSecondPrice (float secondPrice)

Method to get pub's second price back for sdk

Parameters
secondPrice unit is points

public void setVideoEventListener (VideoEventListener listener)

Method to add or update the video events listener for pub

Parameters
listener Represents the new listener

public void showOnLockScreen (InMobiNative.LockScreenListener lockScreenListener)

Call this method to inform SDK that this Ad will be shown on LockScreen. This method should be called before load(Context) or load().

public void takeAction ()

Call this method to take action which is caused by any user interaction with ad view on Lockscreen. This interaction will be reported by

See Also