Integrating an Ad Spot

Introduction

Integrating an Ad Spot allows you to integrate the following ad types into your SDK:

  • Banner
  • Medium rectangle
  • Medium rectangle video
  • Square video
  • Landscape video

Step 1: Adding the Ad Spot

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

Add the Spot Integration

// spot integration for display Square
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, Square video and Landscape 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.

  1. It's time to set up the ad request.

Setting Up Your Ad Request

InneractiveAdRequest adRequest = new InneractiveAdRequest("");
 
// enriching with user and keywords data
// 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

Choose the type of listening event you would like:

Listening Request
Listening Video

Step 3: Displaying the Ad

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

Setting Up Displaying the Ad

// checking 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: Defining the Ad Layout

  1. After you've added the ad spot, it's time to define the ad layout.

Define Your Ad Layout

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

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

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

Next Steps

Click the links below to add another ad type.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request