Class InMobiNative
- java.lang.Object
-
- com.inmobi.ads.InMobiNative
-
public final class InMobiNative extends java.lang.Object
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
InMobiNative.LockScreenListener
A listener for receiving Lockscreen events during the lifecycle of a Native ad.static class
InMobiNative.NativeCallbacks
-
Constructor Summary
Constructors Constructor Description InMobiNative(android.content.Context context, long placementId, NativeAdEventListener listener)
Creates an instance ofInMobiNative
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
destroy()
Destroy the Native ad view.java.lang.String
getAdCtaText()
java.lang.String
getAdDescription()
java.lang.String
getAdIconUrl()
java.lang.String
getAdLandingPageUrl()
org.json.JSONObject
getAdMetaInfo()
Deprecated.float
getAdRating()
java.lang.String
getAdTitle()
java.lang.String
getCreativeId()
Deprecated.org.json.JSONObject
getCustomAdContent()
android.view.View
getPrimaryViewOfWidth(android.content.Context context, android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
Method to return a native ad view.android.view.View
getPrimaryViewOfWidth(android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
Deprecated.void
getSignals()
Called to create the request payload & the value is returned inAdEventListener.onRequestPayloadCreated(byte[])
callback on success, and in case of failureAdEventListener.onRequestPayloadCreationFailed(InMobiAdRequestStatus)
is invoked.boolean
isAppDownload()
boolean
isReady()
Returnstrue
if the native was loaded successfully and is ready to be shown.java.lang.Boolean
isVideo()
This api provides information if the ad returned contains a video or not.void
load()
Submit a request to load Native ad.void
load(byte[] response)
Called to render the ad with the provided response.void
load(android.content.Context context)
Submit a request to load ad content.void
pause()
Pauses any extra processing associated with thisInMobiNative
ad.void
reportAdClickAndOpenLandingPage()
void
resume()
Resumes anInMobiNative
ad after a previous call topause()
.void
setContentUrl(java.lang.String contentUrl)
Set the current context of the app.void
setExtras(java.util.Map<java.lang.String,java.lang.String> extras)
Set any additional custom parameters that will be sent in the ad request.void
setKeywords(java.lang.String keywords)
Set comma delimited keywords for targeting purposevoid
setListener(NativeAdEventListener listener)
Method to update the pub listenervoid
setVideoEventListener(VideoEventListener listener)
Method to add or update the video events listener for pubvoid
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.
-
-
-
Constructor Detail
-
InMobiNative
public InMobiNative(android.content.Context context, long placementId, NativeAdEventListener listener) throws SdkNotInitializedException
Creates an instance ofInMobiNative
.- Parameters:
context
- Provide the current context instanceplacementId
- The placementId for which the object is createdlistener
- Listener to get lifecycle callbacks- Throws:
SdkNotInitializedException
- If the IM-SDK was not initialized before creating ad object
-
-
Method Detail
-
setListener
public void setListener(NativeAdEventListener listener)
Method to update the pub listener- Parameters:
listener
- Represents the new listener
-
setVideoEventListener
public void setVideoEventListener(VideoEventListener listener)
Method to add or update the video events listener for pub- Parameters:
listener
- Represents the new listener
-
getSignals
public void getSignals()
Called to create the request payload & the value is returned inAdEventListener.onRequestPayloadCreated(byte[])
callback on success, and in case of failureAdEventListener.onRequestPayloadCreationFailed(InMobiAdRequestStatus)
is invoked.
-
load
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 throughNativeAdEventListener
listener.- Parameters:
response
- Represents the response to be used to render an ad
-
load
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 theNativeAdEventListener
callback that it supplied while instantiating anInMobiNative
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.
-
load
public void load(android.content.Context context)
Submit a request to load ad content. Use this method in order to change the context where the ad needs to originally load.- Parameters:
context
- theContext
where the ad will be rendered.
-
showOnLockScreen
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 beforeload(Context)
orload()
.- Parameters:
lockScreenListener
-
-
takeAction
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
-
pause
public final void pause()
Pauses any extra processing associated with thisInMobiNative
ad. Your app must call this method in theonPause
method of the containing activity or fragment.While using
InMobiNative
with the following constructorInMobiNative(Context, long, NativeAdEventListener)
}, or usingload(Context)
where context as activity there is no need to callpause()
.
-
resume
public final void resume()
Resumes anInMobiNative
ad after a previous call topause()
. Your app must call this method in theonResume
method of the containing activity or fragment.While using
InMobiNative
with the following constructorInMobiNative(Context, long, NativeAdEventListener)
},or usingload(Context)
where context as activity there is no need to callresume()
}.
-
getPrimaryViewOfWidth
public android.view.View getPrimaryViewOfWidth(android.content.Context context, android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
Method to return a native ad view. This method should be called only when theNativeAdEventListener#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.
-
getPrimaryViewOfWidth
@Deprecated public android.view.View getPrimaryViewOfWidth(android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
Deprecated.- 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.
- See Also:
NativeAdEventListener#onAdLoadSucceeded(InMobiNative)
-
getCustomAdContent
public org.json.JSONObject getCustomAdContent()
-
getAdTitle
public java.lang.String getAdTitle()
-
getAdDescription
public java.lang.String getAdDescription()
-
getAdIconUrl
public java.lang.String getAdIconUrl()
-
getAdLandingPageUrl
public java.lang.String getAdLandingPageUrl()
-
getAdCtaText
public java.lang.String getAdCtaText()
-
getAdRating
public float getAdRating()
-
isAppDownload
public boolean isAppDownload()
-
isVideo
public java.lang.Boolean isVideo()
This api provides information if the ad returned contains a video or not. It returnstrue
if the ad contains a video and returnsfalse
vice versa. It will returnnull
if this method is called in a wrong state, i.e., can be called only after theNativeAdEventListener#onAdLoadSucceeded(InMobiNative)
callback is given.- Returns:
- a Boolean if the ad returned contains a video or not
-
reportAdClickAndOpenLandingPage
public void reportAdClickAndOpenLandingPage()
-
isReady
public boolean isReady()
Returnstrue
if the native was loaded successfully and is ready to be shown.- Returns:
-
getAdMetaInfo
@Deprecated public org.json.JSONObject getAdMetaInfo()
Deprecated.This method has been deprecated, please useAdMetaInfo.getBidInfo()
inNativeAdEventListener#onAdFetchSuccessful(InMobiNative, AdMetaInfo)
instead. Returns meta info about Ad if any such info is available otherwise returns emptyJSONObject
- Returns:
- JSONObject
-
setExtras
public void setExtras(java.util.Map<java.lang.String,java.lang.String> extras)
Set any additional custom parameters that will be sent in the ad request.- Parameters:
extras
- additional custom parameters
-
setKeywords
public void setKeywords(java.lang.String keywords)
Set comma delimited keywords for targeting purpose- Parameters:
keywords
- comma delimited keywords
-
setContentUrl
public void setContentUrl(java.lang.String contentUrl)
Set the current context of the app.- Parameters:
contentUrl
- - Represents the contentUrl of the app
-
destroy
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.
-
getCreativeId
@Deprecated public java.lang.String getCreativeId()
Deprecated.This method has been deprecated, please useAdMetaInfo.getCreativeID()
inNativeAdEventListener#onAdFetchSuccessful(InMobiNative, AdMetaInfo)
instead. Returns creativeId if the Native ad was loaded successfully and creativeId is available otherwise returns empty string.- Returns:
- String
-
-