Banner Integration for Android

Banners are rectangular, system-initiated ads that can be either static or animated that are served in a designated area around your live app content.

Before You Start

  • Make sure that you have correctly integrated the ironSource SDK into your application. Integration is outlined here.
  • Banner Mediation is supported in ironSource SDK 6.6.0 and above.
  • You will need to integrate one of our mediation adapters with Banner support to serve this ad unit.

Step 1. Create Banner Layout 

First, you’ll need to create a Banner view to configure the Banner.

  • Instantiate the Banner view by calling this method:
    IronSourceBannerLayout mIronSourceBannerLayout = IronSource.createBanner(this, bannerAdSize);
    
    Note: You must define one of Banner sizes we support in order to set the BannerLayout. See table below.
    bannerAdSize Description Dimensions Ad Network Support
    BANNER Standard Banner
    Best for Phones & Tablets
    320X50 Admob, Facebook, InMobi
    LARGE Large Banner 320X90 Admob, Facebook
    RECTANGLE Large Rectangular Banner
    Best for Scrollable Feeds or Between Game Levels
    300X250 Admob, Facebook, InMobi
    TABLET Tablet Banner
    Best for Tablets and Larger Devices
    728X90 Admob, Facebook, InMobi
  • Attach the Banner to your app’s existing view container in order to enable your users to view the Banner:
    FrameLayout mBannerParentLayout = (FrameLayout) findViewById(R.id.your_banner_container);
    FrameLayout.LayoutParams layoutParams = new 
    FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
    mBannerParentLayout.addView(mIronSourceBannerLayout, 0, layoutParams);
Note: For Admob Banners
If you are leveraging Admob’s banner ads through ironSource Mediation, make sure all the parent containers for the banners do not have any width padding defined. This is necessary for the Admob Smart Banner as this ad unit adjusts to the optimal ad size in accordance with the width of the device in its current orientation. In order to calculate the width of the screen correctly, the padding properties must be removed.

Step 2. Implement the Listener

Next, implement the Banner Listener in your code. The ironSource SDK fires several callbacks to inform you of Banner activity. The SDK will notify your Listener of all possible events listed below:

mIronSourceBannerLayout.setBannerListener(new BannerListener() {
                @Override
                public void onBannerAdLoaded() {
                }
                @Override
                public void onBannerAdLoadFailed(IronSourceError error) {
                }
                @Override
                public void onBannerAdClicked() {
                }
                @Override
                public void onBannerAdScreenPresented() {
                }
                @Override
                public void onBannerAdScreenDismissed() {
                }
                @Override
                public void onBannerAdLeftApplication() {
                }
            });
Note: Do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from ironSource callbacks need to be passed to the main thread before executing.

Step 3. Load Banner Ad

To load a Banner ad, call the following method:

IronSource.loadBanner(mIronSourceBannerLayout);

We support placements, as well as capping and pacing for Banners on the ironSource dashboard. Learn how to set up placements, capping and pacing for Banners to optimize your app’s user experience here.

If you’ve set up placements for your Banner, call the following method to serve a Banner ad in a specific location:

IronSource.loadBanner(mIronSourceBannerLayout, placement);

Once you receive the below callback from your Listener, you will be able to show the ad to your users:

IronSource.onBannerAdLoaded(){}

Step 4. Destroy the Banner Ad

Once you’ve successfully served a Banner, we recommend calling the below function to destroy the previous Banner. This is necessary to serve an additional Banner in the same view.

IronSource.destroyBanner(mIronSourceBannerLayout);

After you call this method, the Banner in question can no longer be used. In the case you want to serve it again, you will need to create a new Banner using the createBanner method.

Step 5.  Integrate a Banner Provider

Next, integrate the ad network adapters to serve Banners through ironSource Mediation. We currently support AdmobFacebook and Inmobi Banners.

 

Done!
You are now all set up to serve Banners in your application. Verify your integration with our Integration Helper.


What’s Next? 

Follow our integration guides to integrate additional ad units:

 

Interested in integrating more mediation adapters? Check out our supported Mediation Networks.