Skip to content

Showing Banner Ads

sdk-jenkins edited this page Mar 10, 2022 · 7 revisions

Once you've performed the required project setup, you can display an AdColony banner ad in your app in a few easy steps:

Step 1: Import and Configure AdColony

First, make sure you have imported the AdColony library:

import com.adcolony.sdk.*;

Next, in your Activity's onCreate method, call configure like so:

@Override
protected void onCreate(Bundle bundle) {
  super.onCreate(bundle);
  AdColony.configure(this, APP_ID);
  ...
}

Replace APP_ID and ZONE_IDS with your app and zone ids gathered from the AdColony Dashboard (please refer to "Publisher Apps & Zones Setup" for help).

Step 2: Request and Display a Banner Ad

Next, create an AdColonyAdViewListener, choose an ad size and request an ad.

AdColonyAdViewListener listener = new AdColonyAdViewListener() {
    @Override
    public void onRequestFilled(AdColonyAdView ad) {
        /** Add this ad object to whatever layout you have set up for this placement */
    }
};

AdColony.requestAdView(ZONE_ID, listener, AdColonyAdSize.BANNER);

Step 3: Destroy the Banner Ad

Lastly, when you have removed the view from your layout and are no longer planning on making use of it, call destroy() so that we can destroy the view and clean up any internal references.

ad.destroy();

Clone this wiki locally