public final class InMobiNative
extends java.lang.Object
Note This class is not thread-safe. All methods on instances of this class must be called on the UI thread.
Modifier and Type | Class and Description |
---|---|
static interface |
InMobiNative.LockScreenListener
A listener for receiving Lockscreen events during the lifecycle of a Native ad.
|
static class |
InMobiNative.NativeCallbacks |
Constructor and Description |
---|
InMobiNative(android.content.Context context,
long placementId,
NativeAdEventListener listener)
Creates an instance of
InMobiNative . |
Modifier and Type | Method and 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 in
AdEventListener.onRequestPayloadCreated(byte[]) callback on success, and in
case of failure
AdEventListener.onRequestPayloadCreationFailed(InMobiAdRequestStatus) is
invoked. |
boolean |
isAppDownload() |
boolean |
isReady()
Returns
true 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 this
InMobiNative ad. |
void |
reportAdClickAndOpenLandingPage() |
void |
resume()
Resumes an
InMobiNative ad after a previous call to pause() . |
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 purpose
|
void |
setListener(NativeAdEventListener listener)
Method to update the pub listener
|
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.
|
public InMobiNative(android.content.Context context, long placementId, NativeAdEventListener listener) throws SdkNotInitializedException
InMobiNative
.context
- Provide the current context instanceplacementId
- The placementId for which the object is createdlistener
- Listener to get lifecycle callbacksSdkNotInitializedException
- If the IM-SDK was not initialized before creating ad objectpublic void setListener(NativeAdEventListener listener)
listener
- Represents the new listenerpublic void setVideoEventListener(VideoEventListener listener)
listener
- Represents the new listenerpublic void getSignals()
AdEventListener.onRequestPayloadCreated(byte[])
callback on success, and in
case of failure
AdEventListener.onRequestPayloadCreationFailed(InMobiAdRequestStatus)
is
invoked.public void load(byte[] response)
NativeAdEventListener
listener.response
- Represents the response to be used to render an adpublic void load()
NativeAdEventListener
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(android.content.Context context)
context
- the Context
where the ad will be rendered.public void showOnLockScreen(InMobiNative.LockScreenListener lockScreenListener)
load(Context)
or load()
.lockScreenListener
- public void takeAction()
public final void pause()
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 final void resume()
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 android.view.View getPrimaryViewOfWidth(android.content.Context context, android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
NativeAdEventListener#onAdLoadSucceeded(InMobiNative)
callback was provided.context
- Context in which ad will be rendered.convertView
- Recycled view provided by the Adapter.parent
- The parent for the primary view@Deprecated public android.view.View getPrimaryViewOfWidth(android.view.View convertView, android.view.ViewGroup parent, int viewWidthInPixels)
convertView
- Recycled view provided by the Adapter.parent
- The parent for the primary viewNativeAdEventListener#onAdLoadSucceeded(InMobiNative)
public org.json.JSONObject getCustomAdContent()
public java.lang.String getAdTitle()
public java.lang.String getAdDescription()
public java.lang.String getAdIconUrl()
public java.lang.String getAdLandingPageUrl()
public java.lang.String getAdCtaText()
public float getAdRating()
public boolean isAppDownload()
public java.lang.Boolean isVideo()
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 NativeAdEventListener#onAdLoadSucceeded(InMobiNative)
callback
is given.public void reportAdClickAndOpenLandingPage()
public boolean isReady()
true
if the native was loaded successfully and is ready to be shown.@Deprecated public org.json.JSONObject getAdMetaInfo()
AdMetaInfo.getBidInfo()
in
NativeAdEventListener#onAdFetchSuccessful(InMobiNative, AdMetaInfo)
instead.
Returns meta info about Ad if any such info is available otherwise returns empty JSONObject
public void setExtras(java.util.Map<java.lang.String,java.lang.String> extras)
extras
- additional custom parameterspublic void setKeywords(java.lang.String keywords)
keywords
- comma delimited keywordspublic void destroy()
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.
@Deprecated public java.lang.String getCreativeId()
AdMetaInfo.getCreativeID()
in
NativeAdEventListener#onAdFetchSuccessful(InMobiNative, AdMetaInfo)
instead.
Returns creativeId if the Native ad was loaded successfully and creativeId is available
otherwise returns empty string.