Android application display Video Ads

The preparation for coding

Before reading this tutorial, please read the android ads based tutorial to learn how to get access management of library, how to install AD management library, how to add advertising platform configuration information

Add advertising related Java code

1. import keymob related classes
    import com.keymob.networks.AdManager;
    import com.keymob.networks.core.*;
import com.keymob.sdk.core.AdTypes;
2.set the parameters of ad platforms
Platform parameters in json format as follow
    	{
		"isTesting":true,//Whether the test mode
		"rateModel":1,//Advertising platform collation, 0 means is the priority weights, 
//different platform scale display ads, 1 is the priority order, the platform to display ads in sequence	
		"platforms":[
		{"class":"AdmobAdapter","priority":90,"key1":"ca-app-pub-xxx/xxx","key2":"ca-app-pub-xxx/xxx"},
//admob platforms ,key1 banner ID,key2 full screen id
		{"class":"AmazonAdapter","priority":20,"key1":"xxx"},//amazon platform ,key1 appkey
		{"class":"ChartboostAdapter","priority":40,"key1":"xxx","key2":"xxx"},
//chartboost platform ,key1 appID,key2 signature
		{"class":"InmobiAdapter","priority":50,"key1":"xxx"},//inmobi platform ,key1 appid
		{"class":"IadAdapter","priority":50,"key1":"877393773"},
//iad platform ,androidandroid Will automatically be ignored
		{"class":"KeymobAdapter","priority":50,"key1":"appid"},
//keymob.com Since the sale of advertising, cross promotion needs	
		{"class":"BaiduAdapter","priority":50,"key1":"appsid","key2":"appsec"},//baidu platform
    {"class":"GDTAdapter","priority":50,"key1":"appid","key2":"banner id","param":"full id"},//wide point  platform
    {"class":"AdcolonyAdapter","priority":50,"key1":"appid","key2":"full id","param":"video id"},//adcolony platform
		{"class":"MMediaAdapter","priority":10,"key1":"xxx","key2":"xxx"}
//mmedia platform ,key1 banner ID,key2full screenid
		]
	}
3.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);
4.Load the video advertising
AdManager.getInstance().loadVideo();
5.Check whether the video advertising is loaded successfully
AdManager.getInstance().isVideoReady();
6.Show video advertising
AdManager.getInstance().showVideo();
7.Android display video ads
Display ads before loading, the following style is a well way
    if(AdManager.getInstance().isVideoReady()){
		AdManager.getInstance().showVideo();
	}

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