Configure a banner ad space
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
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.Use one of the following methods to pre-configure
CdpAdvertisementViewon the app page that you created in Step 1.Pre-configure the
CdpAdvertisementViewparameters 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
CdpAdvertisementViewparameters using Java:CdpAdvertisementView cdpView = new CdpAdvertisementView(context); parentView.addView(cdpView);
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 IDAfter you configure the ad space in the console, the information obtained from the server-side populates the
CdpAdvertisementViewparameters.In the
AndroidManifestfile, addAdvertisementBoothActivity.
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.