Banner Video Ads Integration for Android

Do go through the steps in our Getting Started Guide to add Media.Net SDK into your project before starting the integration of Banner Ads.

For adding banner ads to your app, following are the steps:

  • Defining ad slot
  • Loading an ad in the slot
  • Setting up listeners

    a. Define a slot for your banner ad in your layout XML.

    The SDK provides a custom View subclass, MNetView, which handles requesting and loading ads.

    Include this XML block to your activity’s or fragment’s layout.


    b. Load an ad into the banner slot

          MNetView mnetView = (MNetView)findViewById(;
          mnetView.setAdUnitId("xxxxxxxxxxx");//Enter your Ad Unit ID

    c. Listen to the ad state :

    MNetView provides a listener interface, AdListener, which can be used to stay informed about the ad lifecycle events. AdListener has the following methods.

         mnetView.addListener(new AdListener() {
            // Sent when the ad slot successfully retrieved a Banner ad.
            public void onAdLoaded() {
               //Do your stuff
            // Sent when the ad slot has failed to retrieve an ad.
            public void onError(final MNetError error) {
               //Do your stuff
            // Sent when the user has tapped on the Banner ad.
            public void onAdClicked() {
               //Do your stuff
            // Sent when the user closes the Ad
            public void onAdClosed() {
               //Do your stuff