public final class

InMobiBanner

extends RelativeLayout
java.lang.Object
   ↳ RelativeLayout
     ↳ com.inmobi.ads.InMobiBanner

Class Overview

Use this class to integrate banner ads in your application.

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

Summary

Nested Classes
enum InMobiBanner.AnimationType Enumeration for the view transitions during a banner ad refresh. 
interface InMobiBanner.BannerAdListener A listener for receiving notifications during the lifecycle of a banner ad. 
interface InMobiBanner.BannerAdRequestListener A listener to notify the outcome of a prefetch ad request. 
Public Constructors
InMobiBanner(Context context, AttributeSet attributeSet)
Construct an InMobiBanner instance from XML layouts.
InMobiBanner(Context context, long placementId)
Construct an InMobiBanner instance.
Public Methods
void disableHardwareAcceleration()
Turn off hardware acceleration on the underlying views.
float getAdBid()
Returns bid info about Ad if console open bid info available otherwise returns 0
JSONObject getAdMetaInfo()
Returns meta info about Ad if any such info is available otherwise returns empty JSONObject
String getCreativeId()
Returns creativeId if the banner was loaded successfully and creativeId is available otherwise returns empty string.
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.
void load()
Submit a request to load ad content.
void load(byte[] response)
Called to render the ad with the provided response.
void load(Context context)
Submit a request to load ad content.
void onWindowFocusChanged(boolean hasWindowFocus)
final void pause()
Pauses any extra processing associated with this InMobiBanner ad.
static void requestAd(Context context, InMobiAdRequest adRequest, InMobiBanner.BannerAdRequestListener listener)
Request for a banner ad.
final void resume()
Resumes an InMobiBanner ad after a previous call to pause().
void setAnimationType(InMobiBanner.AnimationType animationType)
Set the animation preference on the banner views during ad refresh.
void setBannerSize(int widthInDp, int heightInDp)
Set the width and height of Banner.
void setEnableAutoRefresh(boolean enabled)
Control if the banner should auto-refresh ad content.
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(InMobiBanner.BannerAdListener listener)
Set a listener to be notified of lifecycle events for the InMobiBanner instance.
void setListener(BannerAdEventListener listener)
Set a listener to be notified of lifecycle events for the InMobiBanner instance.
void setRefreshInterval(int refreshInterval)
Specify the refresh interval for the banner ad.
void setmFirstIn(boolean mFirstIn)
Internal use only
Protected Methods
void onAttachedToWindow()
void onVisibilityChanged(View changedView, int visibility)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public InMobiBanner (Context context, AttributeSet attributeSet)

Construct an InMobiBanner instance from XML layouts.

Parameters
context Represents the context where the banner is going to be shown
attributeSet Represents the AttributeSet properties of banner in XML

public InMobiBanner (Context context, long placementId)

Construct an InMobiBanner instance.

Parameters
context Represents the context where the banner is going to be shown
placementId Represents the placement-ID of the banner ad

Public Methods

public void disableHardwareAcceleration ()

Turn off hardware acceleration on the underlying views.

public float getAdBid ()

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

Returns
  • float

public JSONObject getAdMetaInfo ()

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

Returns
  • JSONObject

public String getCreativeId ()

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

Returns
  • String

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 void load ()

Submit a request to load ad content. This method returns immediately upon enqueuing a request. Your application shall be notified of the result on the InMobiBanner.BannerAdListener callback.

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.

See Also

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 BannerAdEventListener listener.

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

public void load (Context context)

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

Parameters
context the Context where the ad will be rendered.

public void onWindowFocusChanged (boolean hasWindowFocus)

public final void pause ()

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

You only need to call this method if you supplied a non-Activity context while creating your banner ad unit, or if you called the load(Context) method on the InMobiBanner instance that was available in the onAdRequestCompleted(InMobiAdRequestStatus, InMobiBanner) event.

public static void requestAd (Context context, InMobiAdRequest adRequest, InMobiBanner.BannerAdRequestListener listener)

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

Note: This method keeps a weak reference to the InMobiBanner.BannerAdRequestListener 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 InMobiBanner.BannerAdRequestListener.

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 InMobiBanner.BannerAdRequestListener implementation that will be called when the ad request completes.

public final void resume ()

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

You only need to call this method if you supplied a non-Activity context while creating your banner ad unit, or if you called the load(Context) method on the InMobiBanner instance that was available in the onAdRequestCompleted(InMobiAdRequestStatus, InMobiBanner) event.

public void setAnimationType (InMobiBanner.AnimationType animationType)

Set the animation preference on the banner views during ad refresh.

public void setBannerSize (int widthInDp, int heightInDp)

Set the width and height of Banner. These values should be same as layout dimensions.

Parameters
widthInDp width of Banner in DP
heightInDp height of Banner in DP

public void setEnableAutoRefresh (boolean enabled)

Control if the banner should auto-refresh ad content.

Parameters
enabled true if banner should auto-refresh, otherwise false

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

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

Parameters
extras Represents the extras

public void setKeywords (String keywords)

Set comma delimited keywords for targeting purpose

Parameters
keywords Represents the keywords

public void setListener (InMobiBanner.BannerAdListener listener)

Set a listener to be notified of lifecycle events for the InMobiBanner instance. Use setListener(BannerAdEventListener) instead.

Parameters
listener Represents the listener to provide callbacks

public void setListener (BannerAdEventListener listener)

Set a listener to be notified of lifecycle events for the InMobiBanner instance.

Parameters
listener Represents the listener to provide callbacks

public void setRefreshInterval (int refreshInterval)

Specify the refresh interval for the banner ad.

Parameters
refreshInterval Represents the interval at which the banner ad will refresh

public void setmFirstIn (boolean mFirstIn)

Internal use only

Protected Methods

protected void onAttachedToWindow ()

protected void onVisibilityChanged (View changedView, int visibility)