Before You Start

Before integrating ads unit in your app, you must:


Banners are rectangular, system-initiated ads that served in a designated area around your live app content.

BannerAd Formats:

Image text

Step 1. Init Banner Ad

The AdTiming SDK fires several events to inform you of Banner Ad activity. To display Banner Ads, one needs to create a brand new BannerAd object, setup its listeners and load the ads.

The following snippet demonstrates how to use the BannerAd class to create BannerAd objects and implement the BannerAdListener interface to receive Native Ad events. The SDK will notify the Listener of all possible events listed below:

import com.aiming.mdt.banner.BannerAd;
import com.aiming.mdt.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(). 
      public void onAdReady(View view) {
          // bannerAd is load success

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

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


Step 2. Load BannerAd

Invoke loadAd method to request and cache the Banner Ad before it is available for display to users. It is strongly recommended to invoke this method a short while before the ad is to be shown.  



  • The loadAd method could be called multiple times at any time, but we do not recommend continuous requests for a short period of time. Many requests in a short period of time have no added value because the opportunities of available for inventory is unlikely at this time. 
  • !Warning: Attempting to load a new ad from the onAdFailed() methods is strongly discouraged. If you must load an ad from onAdFailed() ensure to limit ad load retries to avoid continuous failed ad requests in situations such as limited network connectivity.


Step 3. Show BannerAd

After the Interactive Ad is successfully loaded by calling the loadAd in Step 2, you will be notified when the ad is ready to be shown through the onAdReady callback which will inform you the avaliability of ad inventory. 

Once you receive the onAdReady callback, you  can use code belows to show and serve the Banner Ad to your users.

 private RelativeLayout adParent;
 adParent = this.findViewById(;

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

■ code as following:




Step 4. Destory BannerAd Object

It is recommended to invoke destroy method to release BannerAd object when the Activity be destroyed.

public void onDestroy() {
if (bannerAd != null) {
Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.