Repository navigation
Showing Banner Ads
sdk-jenkins edited this page Mar 10, 2022
·
7 revisions
- Project Setup
- Showing Interstitial Ads
- Showing Rewarded Interstitial Ads
- Showing Banner Ads
- Privacy Laws
- SDK API Details
- Publisher Reporting API
Once you've performed the required project setup, you can display an AdColony banner ad in your app in a few easy steps:
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).
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);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();
Made with ❤️ in Seattle