Class InMobiNative

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface InMobiNative.LockScreenListener

      A 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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • InMobiNative

        InMobiNative(Context context, Long placementId, NativeAdEventListener listener)
        Parameters:
        context - Provide the current context instance
        placementId - The placementId for which the object is created
        listener - Listener to get lifecycle callbacks
    • Method Detail

      • 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 null if 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 null if 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 null if 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 null if 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 0 if 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 null if 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 null if 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 null if 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 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 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 auction
        auctionPrice - 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 null if 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.