Get Started with Avocarrot

Overview

Examples

Android

Overview

- Avocarrot Exchange SDK

Setup Exchange SDK

Stream

Native Assets

Exchange Troubleshooting

- Avocarrot Mediation SDK

Setup Mediation

Stream Ads Mediation

Native ads Mediation

Native Assets Mediation

Banner Mediation

Interstitial Mediation

Video Mediation

Supported Networks & Ad Types

Mediation Troubleshooting

iOS

Overview

- Avocarrot Exchange SDK

Setup SDK

Stream

Native Assets

Exchange Troubleshooting

- Avocarrot Mediation

Getting Started With Mediation

Stream Ads Mediation

Native Ads Mediation

Banner Ads Mediation

Interstitial Ads Mediation

Video Ads Mediation

Supported Networks & Ad Types

Mediation Troubleshooting

API Documentation

Reporting API

Help

FAQ

Updates

SDK Change Log

Android Change Log

iOS Change Log

Banner Mediation

Updated 7 days ago ​by Derek Lim

Overview

This tutorial helps you setup banner ads mediation.

Prerequisites

You need an Avocarrot account to complete the tutorial. Create an account
You need to setup the Mediation SDK. Setup Mediation SDK

Setup Banner Mediation

All SDK method calls should be done from the main thread (Main thread, UI thread).

ID of advertising space for testing : "3dfbb889-3bcd-4c34-82ae-8fcb539c3b25"

The ID above is meant for testing purpose only, please replace it with the Ad unit Id of your placement on dashboard.
  1. Add a banner to layout file, e.g.:


    <FrameLayout
        android:id="@+id/ad_view"    
        android:layout_width="320dp"
        android:layout_height="50dp"
        android:background="@android:color/white"/>

    It is advisable to make the banner size in the layout the same as the required one (see below). Otherwise, the banner might be displayed incorrectly.

    Add the following code to your activity:


    FrameLayout adView = (FrameLayout) findViewById(R.id.ad_view);
    BannerAd bannerAd = BannerAdPool.load(this, "YOUR_BANNER_AD_UNIT_ID", adView, BannerSize.BANNER_SIZE_320x50, bannerAdListener);
    Banners 320*50 are served by default. Available sizes:
    • 320×50
    • 728×90

    Banner Auto-update
    You can switch the banner auto-update function on or off; to do this, call setAutorefreshEnabled() method, e.g.:
    bannerAd.setAutorefreshEnabled(false);

    By default, auto-update is switched on. The auto-update period is set up via the admin panel.

    If you need to reload Banner manually, call
    bannerAd.reloadAd();

Activity lifecycle events handling 


onPause()onResume() and onDestroy() methods should be called depending on the activity lifecycle events.

Example:

@Override
protected void onPause() {
    super.onPause();
    bannerAd.onActivityPaused();
}
@Override
protected void onResume() {
    super.onResume();
    bannerAd.onActivityResumed();
}
@Override
protected void onDestroy() {
    super.onDestroy();
    bannerAd.onActivityDestroyed();
}
  1. Congratulations! Compile and Run your project. You can now further customize your banner ads.

Advanced Customization

Go Live!

  1. Remove sandbox If you have received a sample ad then simply disable the Sandbox mode by including the following instruction in your code:
    AvocarrotSDK.setTestMode(false);
    You should disable Sandbox mode ONLY when you are done with the integration and you are ready to publish your app. It is against Avocarrot's policies to use live ads during development, and doing so could get your Avocarrot account banned.
  2. Publish app You are now ready to upload your app and start making money! If you have submitted your app in the Google Play/ Apple Store and you can see live ads, then you have nothing to worry about. Just wait until the impressions threshold has been reached and the app will be shown as live in your dashboard as well.
  3. Update payment details. Login to your account and update your payment settings.



Was this article useful?