Android Ad Formats

Banner/MREC Ads Interstitial Ads Rewarded Ads

Integrating Banner/MREC Ads

Integrating an Ad Spot allows you to integrate different ad types into your SDK.  Each option is detailed in the tabs above.

Follow the steps below to integrate Banner/MREC ads into your SDK.

Step 1: Adding the Ad Spot

  1. Add the Ad Spot integration for the display as well as the Adview Controller:

Add the Spot Integration

// Spot integration for display square
InneractiveAdSpot mSpot= InneractiveAdSpotManager.get().createSpot();

// Adding the adview controller
InneractiveAdViewUnitController controller = new
InneractiveAdViewUnitController();
mSpot.addUnitController(controller);
  1. If you want to receive video events for Medium rectangle video, add the video content controller code as well:

Add Video Content Controller

// In case we want to receive video events and increased capabilities we should add the video content controller
// The content controller is added to the ad view controller object
InneractiveAdViewVideoContentController videoContentController = 
new InneractiveAdViewVideoContentController(); controller.addContentController(videoContentController);

Step 2: Making the Ad Request

The request and display steps are separate for the Ad Spot.  It's time to set up the ad request.

Setting Up Your Ad Request

InneractiveAdRequest adRequest = new
InneractiveAdRequest("your_Banner/MREC_spot_id"); // Enriching with user and keywords data (Optional) // For gender values see: InneractiveUserConfig.Gender adRequest.setUserParams( new InneractiveUserConfig() .setGender() .setZipCode("") .setAge()); // Add keywords. Separated by a comma adRequest.setKeywords("pop,rock,music"); // When ready to perform the ad request mSpot.requestAd(adRequest);

Step 2a: Listening to Request Events

The following example illustrates how a RequestListener should be used:

InneractiveAdSpot.RequestListener mSpotListener = new
InneractiveAdSpot.RequestListener() { @Override // When the ad request sends successfully. public void onInneractiveSuccessfulAdRequest(InneractiveAdSpot inneractiveAdSpot) { } @Override // When the ad request fails to send. public void onInneractiveFailedAdRequest(InneractiveAdSpot inneractiveAdSpot, InneractiveErrorCode inneractiveErrorCode) {
} }; mSpot.setRequestListener(mSpotListener);

Step 3: Displaying the Ad

Once you've set up the request, it's time to set up displaying the ad.

Step 3a: Define Your Ad Layout

Defining your ad layout

< LinearLayout
 android:id="@+id/inneractive_ad_layout"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 / >

Step 3b: Setting-Up Displaying an Ad

Setting Up Displaying the Ad

// Check if we have ad content
if(mSpot.isReady()) {
    // Getting the spot's controller
    InneractiveAdViewUnitController controller = (InneractiveAdViewUnitController)mSpot.getSelectedUnitController();
 
    // Getting the ad view container
    ViewGroup layout = (ViewGroup)findViewById(R.id.inneractive_ad_layout);
 
    // Showing the ad
    controller.bindView(layout);
}

Step 4: Listening to the Events

In addition, it shows how to add an event listener properly for receiving Banner/MREC ad callbacks.

controller.setEventsListener(new InneractiveAdViewEventsListener() {
       @Override
       public void onAdImpression(InneractiveAdSpot adSpot) {
           Log.i(TAG, "onAdImpression");
       }
       @Override
       public void onAdClicked(InneractiveAdSpot adSpot) {
           Log.i(TAG, "onAdClicked");
       }
       @Override
       public void onAdWillCloseInternalBrowser(InneractiveAdSpot adSpot) {
           Log.i(TAG, "onAdWillCloseInternalBrowser");
       }
       @Override
       public void onAdWillOpenExternalApp(InneractiveAdSpot adSpot) {
            Log.i(TAG, "onAdWillOpenExternalApp");
       }
       @Override //Since VAMP 7.2.0
       public void onAdEnteredErrorState(InneractiveAdSpot adSpot, AdDisplayError error) {
            Log.i(TAG, "onAdEnteredErrorState");
}
});

Caution

onAdEnteredErrorState Starting from Android Marketplace SDK version 7.5.4, this callback is also invoked in cases where the WebView renderer process has crashed. In such cases, the instance of the AdDisplayError appears as WebViewRendererProcessHasGoneError. If this error was triggered for a banner/mrec, we recommend to destroy the banner/mrec and request a new one. No additional steps are required for interstitial ad units.

You have now completed the process of adding your Ad Spot!

Click here for details of how to dismiss an Ad Spot.

Back to Top ⇧