# Banner

Banner provide a rectangular banner ad, which is generally presented in the app specified area.

Banner Ad Formats:

Image

# Step 1: Initializing Banners

SDK will trigger a series of events to inform the app of the initialization, loading and presentation results of banners.During use of banners, you need to create the BannerAd object, implement and set up the Listener for listening events, and then call the loadAd method to load and present banners.Banners have no show method, so you need to present banners immediately after they are loaded successfully.

The following code example displays how to use the BannerAd object and implement the BannerAdListener interface to listen the banners event.The event types that can be triggered by SDK can be found in the following code.

import com.zeus.gmc.sdk.mobileads.mintmediation.banner.BannerAd;
import com.zeus.gmc.sdk.mobileads.mintmediation.banner.BannerAdListener;
...
BannerAd bannerAd = new BannerAd(activity, placementId,new BannerAdListener() {

  /** 
    * Invoked when Banner Ad are available. 
    * You can then show the video by calling bannerAd.showAd(). 
    */
  @Override
  public void onAdReady(View view) {
      // bannerAd is load success
  }

  /** 
    * Invoked when the end user clicked on the Banner Ad 
    */
  @Override
  public void onAdClicked() {
      // bannerAd click
  }

  /** 
    * Invoked when the call to load a Banner Ad has failed 
    * String error contains the reason for the failure. 
  */
  @Override
  public void onAdFailed(String error) {
      // bannerAd fail
  }
});

# Step 2: Set Banners Size (Optional)

/**
 * Banner sizes supported: Adsize.BANNER(320, 50),
 * Adsize.LEADERBOARD(728, 90),
 * Adsize.MEDIUM_RECTANGLE(300, 250),
 * Adsize.SMART(-1, -1),
*/
bannerAd.setAdSize(adSize);

For details on standard banners size we support, please see the table below:

AdSize Description Dimensions in dp (WxH)
AdSize.BANNER Standard Banner 320 x 50
AdSize.MEDIUM_RECTANGLE Medium Rectangular Banner 300 x 250
AdSize.LEADERBOARD LeaderBoard Banner 728 x 90
AdSize.SMART Smart Banner (Adjusted for both mobile and tablet) If (screen height ≤ 720) 320 x 50 If (screen height > 720) 728 x 90

# Step 3: Load Banners

You need to call the loadAd method to request and cache banners before presentation of banners.We recommend that you call the loadAd method ahead of time before presentation of banners, to prevent from affecting the banners experience.

bannerAd.loadAd();

WARNING

Warning: The loadAd method can be called for multiple times at the same time, but we do not propose to do so.For the continuous call in a short time will not increase the fill rate of banners. If there is already a loading in progress, the new request will not be processed.

WARNING

Warning: It is very dangerous to load banners in the onAdFailed callback event. If you have to load banners here, you must set a time interval limit to avoid the continuous failure causes the endless loop of program due to no network.

# Step 4: Present Banners

After the banners in step 2 are loaded successfully, the app will receive the onAdReady event, indicating that the banners are cached successfully.Once the onAdReady event is received, you can present banners. Please refer to the following code example.

private RelativeLayout adParent;
 ...
 adParent = this.findViewById(R.id.native_ad_container);
 ...

 @Override
public void onAdReady(View view) {
  // bannerAd is loaded successfully
  if (null != view.getParent()) {
      ((ViewGroup) view.getParent()).removeView(view);
  }
  adParent.removeAllViews();
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
  RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
  adParent.addView(view, layoutParams);
}

The R.id.native_ad_container code is shown as follows:

<RelativeLayout
  android:id="@+id/native_ad_container"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

</RelativeLayout>

# Step 5: Destroy BannerAd Object

We recommend that you call the destroy method to release the BannerAd object before Activity is destroyed.

@Override
public void onDestroy() {
   if (bannerAd != null) {
      bannerAd.destroy();
   }
   super.onDestroy();
}

# Step 6: Support Network Banner Size

You can find the supported network and each network banner size below:

Platforms BANNER MEDIUM_RECTANGLE LEADERBOARD SMART
AdMob Banner Medium Rectangle Leaderboard Smart
Facebook Banner Medium Rectangle Leaderboard Banner / Leaderboard
Mint Banner Medium Rectangle - Banner
UnityAds Banner - Leaderboard Banner / Leaderboard
Vungle Banner - Leaderboard Banner / Leaderboard
AppLovin Banner Medium Rectangle Leaderboard Banner / Leaderboard
IronSource Banner Medium Rectangle Leaderboard Smart
Pangle Banner Medium Rectangle - Banner

# Up Next

You can aggregate other ad types based on our integration documents or test your integration: