Class InMobiNative
-
- All Implemented Interfaces:
public final class InMobiNativeCreates an instance of InMobiNative.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceInMobiNative.LockScreenListenerA listener for receiving lock screen events during the lifecycle of a native ad.
Register this listener only if your app renders native ads on the lock screen. This interface provides callbacks for handling user interactions that require unlocking the device.
-
Constructor Summary
Constructors Constructor Description InMobiNative(Context context, Long placementId, NativeAdEventListener listener)
-
Method Summary
Modifier and Type Method Description final UnitsetListener(NativeAdEventListener listener)Method to update the pub listener final UnitsetVideoEventListener(VideoEventListener listener)Method to add or update the video events listener for pub final UnitshowOnLockScreen(InMobiNative.LockScreenListener lockScreenListener)Call this method to inform SDK that this Ad will be shown on LockScreen. final Unitload(ByteArray response)Called to render the ad with the provided response. final Unitload()Submit a request to load Native ad. final UnitregisterViewForTracking(InMobiNativeViewData inMobiNativeViewData)Registers views for tracking ad impressions and user interactions. final UnitunTrackViews()Removes tracking from all previously registered views. final UnittakeAction()Executes the action triggered by user interaction on the lock screen. final StringgetAdTitle()This api provides the title of the Native Ad. final StringgetAdDescription()This api provides the description of the Native Ad. final InMobiNativeImagegetAdIcon()This api provides the Icon Image Object of the Native Ad. final StringgetCtaText()This api provides the call to action text of the Native Ad. final FloatgetAdRating()This api provides the rating of the Native Ad. final StringgetAdvertiserName()This api provides the advertiser name of the Native Ad. final MediaViewgetMediaView()This api provides the MediaView of the Native Ad. final ViewgetAdChoiceIcon()This api provides the adChoices icon of the Native Ad. final BooleanisVideo()This api provides information if the ad returned contains a video or not. final UnitnotifyWin(Double minBidToWin)Notify the SDK that the bid for this ad was won. final UnitnotifyLoss(Integer lossReason, Double auctionPrice)Notify the SDK that the bid for this ad was lost. final JSONObjectgetAdContent()This api provides additional information about the ad content. final BooleanisReady()Checks if the native ad is ready to be displayed. final UnitsetExtras(Map<String, String> extras)Sets additional custom parameters for the ad request. final UnitsetKeywords(String keywords)Sets comma-delimited keywords for ad targeting. final UnitsetContentUrl(String contentUrl)Sets the content URL for improved ad targeting. final Unitdestroy()Destroys the native ad and releases all associated resources. -
-
Constructor Detail
-
InMobiNative
InMobiNative(Context context, Long placementId, NativeAdEventListener listener)
- Parameters:
context- Provide the current context instanceplacementId- The placementId for which the object is createdlistener- Listener to get lifecycle callbacks
-
-
Method Detail
-
setListener
final Unit setListener(NativeAdEventListener listener)
Method to update the pub listener
- Parameters:
listener- Represents the new listener
-
setVideoEventListener
final Unit setVideoEventListener(VideoEventListener listener)
Method to add or update the video events listener for pub
- Parameters:
listener- Represents the new listener
-
showOnLockScreen
final Unit 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 or .load.
-
load
final Unit load(ByteArray 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
-
load
final Unit 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 NativeAdEventListener callback that it supplied while instantiating an [ ] 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.
-
registerViewForTracking
final Unit registerViewForTracking(InMobiNativeViewData inMobiNativeViewData)
Registers views for tracking ad impressions and user interactions.
This method must be called after the ad has been loaded successfully to enable proper impression tracking and click handling. The provided view data should contain all the views that will display the native ad content.
- Parameters:
inMobiNativeViewData- The view data containing all native ad views to be tracked
-
unTrackViews
final Unit unTrackViews()
Removes tracking from all previously registered views.
This method should be called when the native ad views are no longer visible or when cleaning up to prevent memory leaks and stop tracking activities.
-
takeAction
final Unit takeAction()
Executes the action triggered by user interaction on the lock screen.
This method should be called after the keyguard has been dismissed following an LockScreenListener.onActionRequired callback. It completes the user action that was initiated while the device was locked.
-
getAdTitle
final String getAdTitle()
This api provides the title of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a String
-
getAdDescription
final String getAdDescription()
This api provides the description of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a String
-
getAdIcon
final InMobiNativeImage getAdIcon()
This api provides the Icon Image Object of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a InMobiNativeImage Object or NULL if called in wrong state.
-
getCtaText
final String getCtaText()
This api provides the call to action text of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a String
-
getAdRating
final Float getAdRating()
This api provides the rating of the Native Ad. It will return
0if this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a Float
-
getAdvertiserName
final String getAdvertiserName()
This api provides the advertiser name of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a String
-
getMediaView
final MediaView getMediaView()
This api provides the MediaView of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a Object MediaView
-
getAdChoiceIcon
final View getAdChoiceIcon()
This api provides the adChoices icon of the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a View
-
isVideo
final Boolean isVideo()
This api provides information if the ad returned contains a video or not. It returns
trueif the ad contains a video and returnsfalsevice versa. It will returnnullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given.- Returns:
a Boolean if the ad returned contains a video or not
-
notifyWin
final Unit notifyWin(Double minBidToWin)
Notify the SDK that the bid for this ad was won. This should be called only once per ad.
- Parameters:
minBidToWin- Represents the minimum bid to win the auction
-
notifyLoss
final Unit notifyLoss(Integer lossReason, Double auctionPrice)
Notify the SDK that the bid for this ad was lost. This should be called only once per ad.
- Parameters:
lossReason- Represents the reason code for losing the auctionauctionPrice- Represents the price of the winning bid
-
getAdContent
final JSONObject getAdContent()
This api provides additional information about the ad content. It returns a JSON object containing the additional information in the Native Ad. It will return
nullif this method is called in a wrong state, i.e., can be called only after the NativeAdEventListener.onAdLoadSucceeded callback is given. May contain APP_INSTALLS and LIKES in the JSONObject- Returns:
a JSONObject
-
isReady
final Boolean isReady()
Checks if the native ad is ready to be displayed.
This method returns true if the native ad has been loaded successfully and all required data is available for display. It should be called before attempting to access ad content or display the ad.
- Returns:
true if the ad is ready to be shown, false otherwise
-
setExtras
final Unit setExtras(Map<String, String> extras)
Sets additional custom parameters for the ad request.
These parameters will be included in the ad request and can be used for targeting or passing additional context to the ad server.
- Parameters:
extras- A map of key-value pairs containing additional custom parameters
-
setKeywords
final Unit setKeywords(String keywords)
Sets comma-delimited keywords for ad targeting.
Keywords help improve ad relevance by providing context about the content or user interests. Multiple keywords should be separated by commas.
- Parameters:
keywords- Comma-delimited string of targeting keywords
-
setContentUrl
final Unit setContentUrl(String contentUrl)
Sets the content URL for improved ad targeting.
The content URL helps the ad server understand the context where the ad will be displayed, potentially improving ad relevance and performance.
- Parameters:
contentUrl- The URL of the content where the ad will be displayed
-
destroy
final Unit destroy()
Destroys the native ad and releases all associated resources.
This method performs complete cleanup of the native ad, including stopping any ongoing operations, releasing memory, and clearing references. It must be called when the native ad is no longer needed to prevent memory leaks.
Note: This method must be called on the UI thread. After calling destroy, the InMobiNative instance should not be used again.
-
-
-
-