Android application display banner ads in the relative position
The preparation for coding
Before reading this tutorial, please read the getting startted with android ads to learn how to get library, how to install AD library, how to add configuration information
1. import keymob related classes
import com.keymob.networks.AdManager;
import com.keymob.networks.core.*;
import com.keymob.sdk.core.AdTypes;
2.Initialization Keymob
Initialization Keymob library management is the prerequisite to call other advertising functions , the following is to init with the Keymob.com service
AdManager.getInstance().initFromKeymobService(this, "1", new AdEventListener(), false);
Parameter Description
- “this” the first parameter is AD context, not null
- "1" the second parameter is the Keymob
application ID
- "AdEventListener" Ad event handler impliments IAdEvenntlistener, if you don't plan to deal with
advertising events can be null
- "false" test mode,set to true when debug, set to false when released.
3.Display ads
Show banner ads in the relative position location at the center bottom of the app
AdManager.getInstance().showRelationBanner(BannerSizes.BANNER, BannerPositions.BOTTOM_CENTER,0);
Parameters
Description
- BannerSizes.BANNER first parameter Ad size, all the default support advertising banners size are in
BannerSizes class,
- BannerPositions.BOTTOM_CENTER the second parameter is the relative position of advertising
- " 0" the third parameter is the padding y
Configuration changes
After writing the code, in accordance with the previous tutorial, add permissions configuration and Activity
configuration information
More tutorial of add ad in app qq group 310513042 home