Configure a banner ad space

Updated at:

The console does not support special ad space positions, such as banners. You must pre-configure the ad space in the code on the client. This lets you control properties such as the page and position of the ad space.

The following steps describe how to pre-configure a banner ad space on the client.

Procedure

  1. In your project, create an app page and a corresponding class for ad delivery, such as AdvertisementBoothActivity. You will configure a pre-configured ad space in the banner position on this page.

  2. Use one of the following methods to pre-configure CdpAdvertisementView on the app page that you created in Step 1.

    • Pre-configure the CdpAdvertisementView parameters using XML:

      <com.mpaas.cdp.CdpAdvertisementView
      android:id="@+id/pit_cdp_cav"
      android:layout_width="match_parent"
      android:layout_height="150px"
      android:layout_marginTop="800px"
      android:background="#66ccff"
      />
    • Add the CdpAdvertisementView parameters using Java:

      CdpAdvertisementView cdpView = new CdpAdvertisementView(context);
      parentView.addView(cdpView);
  3. In the onResume() lifecycle method of the activity, call the update method to retrieve other ad space information from the server-side, such as height, display style, and content type.

     cdpView.updateSpaceCode("my_space_code");   // Replace my_space_code with the ad space ID

    After you configure the ad space in the console, the information obtained from the server-side populates the CdpAdvertisementView parameters.

  4. In the AndroidManifest file, add AdvertisementBoothActivity.

You have now configured the pre-configured ad space.

What to do next

After you configure the ad space properties on the client, such as the ID, page, and position, create the corresponding ad space in the console so that activities can call it. The ad space ID in the console must match the ID on the client. For more information, see Create a pre-configured ad space on the client.