Skip to content

Showing Interstitial Ads

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

Once you've performed the required project setup, you can display an AdColony interstitial 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 an Interstitial Ad

Next, create an AdColonyInterstitialListener and request an ad. This request should take place sometime before you plan on displaying the interstitial.

AdColonyInterstitialListener listener = new AdColonyInterstitialListener() {
    @Override
    public void onRequestFilled(AdColonyInterstitial ad) {
        /** Store and use this ad object to show your ad when appropriate */
    }
};

AdColony.requestInterstitial(ZONE_ID, listener);

Step 3: Show the Interstitial Ad

Using the ad object passed back via the AdColonyInterstitialListener, show your ad object when appropriate:

ad.show();

Clone this wiki locally