Mobvista_Native(English) - mobvistateam/Android_SDK_7.6.0 GitHub Wiki
##Native Advertising access method:
If you want to show FaceBook advertisement、adMob advertisement、myTarget advertisement,Please add the following Jar
mobvista_native.jar
AudienceNetwork.jar
google-play-services.jar
myTarget.jar
##FaceBook Special description of polymerization function
FaceBook Requires Android API version 9 or more than 9
facebook SDK Download address :https://developers.facebook.com/docs/android?locale=zh_CN
MyTarget SDK Download address :https://target.my.com/partners/help/sdk/download/
###Pre loaded, the developer can call pre loaded on the previous page, so you need to use the ad page can quickly get ads,If you don't intend to integrate third party SDK,You may not have to add the third party UNITID,for example:You do not intend to integrate Admob ads, you can not add ID_ADMOB_UNITID
public void preload(){
MobVistaSDK sdk = MobVistaSDKFactory.getMobVistaSDK();
Map<String,Object> preloadMap = new HashMap<String,Object>();
preloadMap.put(MobVistaConstans.PROPERTIES_LAYOUT_TYPE, MobVistaConstans.LAYOUT_NATIVE);//Advertising style
preloadMap.put(MobVistaConstans.ID_FACE_BOOK_PLACEMENT, "1611993839047594_1614040148842963");//fbid
preloadMap.put(MobVistaConstans.ID_MY_TARGET_AD_UNITID, "6590");//MyTarget id
preloadMap.put(MobVistaConstans.PREIMAGE,true);//Set to true for pre loading pictures
preloadMap.put(MobVistaConstans.PROPERTIES_UNIT_ID, "12");//unit
//Request the ad category, a total of 2 categories: game and category, app is not a must pass parameters
preloadMap.put(MobVistaConstans.PROPERTIES_API_REUQEST_CATEGORY,
MobVistaConstans.API_REUQEST_CATEGORY_APP);
//preloadMap.put(MobVistaConstans.PROPERTIES_API_REUQEST_CATEGORY,
// MobVistaConstans.API_REUQEST_CATEGORY_GAME)
List<Template> list = new ArrayList<Template>();//To support multiple templates that need to be added
list.add(new Template(MobVistaConstans.TEMPLATE_BIG_IMG, 1));//Support Big picture template, each access to 1 strip
list.add(new Template(MobVistaConstans.TEMPLATE_MULTIPLE_IMG, 1));//Support multi pictrue template, each time for 1 strip
String nativeInfo = MvNativeHandler.getTemplateString(list);//Incoming native_info parameter
preloadMap.put(MobVistaConstans.NATIVE_INFO, nativeInfo);
sdk.preload(preloadMap);
}
- 1.Make sure that SDK is initialized
- 2.initialized MvNativeHandler
MvNativeHandler nativeHandle = new MvNativeHandler(properties, this);
//if necessary facebookPlacementId Role in the request, you can set the following parameters to replace the globalfacebookPlacementId,If you do not set the facebookPlacementId
Map<String,Object> properties = MvNativeHandler.getNativeProperties("12");
properties.put(MobVistaConstans.ID_FACE_BOOK_PLACEMENT, "1611993839047594_1614040148842963");
properties.put(MobVistaConstans.ID_MY_TARGET_AD_UNITID, "6590");//MyTarget ID
properties.put(MobVistaConstans.PROPERTIES_AD_NUM, 1);//Request the number of ads, no default is 1 strip
nativeHandle = new MvNativeHandler(properties, this);
- 3.Using multiple templates (optional)
nativeHandle.addTemplate(new Template(MobVistaConstans.TEMPLATE_BIG_IMG, 1));
nativeHandle.addTemplate(new Template(MobVistaConstans.TEMPLATE_MULTIPLE_IMG, 1));
Figure 1 is ad_num
, the developer can customize
MobVistaConstans.TEMPLATE_BIG_IMG
It represents big picture template,MobVistaConstans.TEMPLATE_MULTIPLE_IMG
It represents multi-map template;
This parameter indicates the type of advertising support, can be used simultaneously. If the ad slot supports two templates, you can by NativeAdListener的onAdLoaded(List<Campaign> campaigns, int template)
middletemlate
Template parameters to determine the type of return
- 4.Add callback,By
MvNativeHandler.setAdListener(NativeAdListener)
and MvNativeHandler.setTrackingListener(NativeTrackingListener)Setting a callback request - 5.By
MvNativeHandler
ofload
The method of loading data - 6.By
registerView(View view)
Register ads appearview
to sdk,Follow-up in this view when clicking to jump directly ad - 7.on Activity of
ondestroy
method,By MvNativeHandlerrelease()
The method of releaseMvNativeHandler
Sample:
//STEP1: Initialization the SDK
MobVistaSDK sdk = MobVistaSDKFactory.getMobVistaSDK();
Map<String,String> map = sdk.getMVConfigurationMap("19343", "7c22942b749fe6a6e361b675e96b3ee9");
sdk.init(map, this);
//STEP2: new nativeController
Map<String,Object> properties = MvNativeHandler.getNativeProperties("12");
properties.put(MobVistaConstans.ID_FACE_BOOK_PLACEMENT, "1611993839047594_1614040148842963");
properties.put(MobVistaConstans.ID_MY_TARGET_AD_UNITID, "6590");//If integrated mytarget, add mytarget of unitId
//Request the ad category, a total of 2 categories: game and category, app is not a must pass parameters
preloadMap.put(MobVistaConstans.PROPERTIES_API_REUQEST_CATEGORY,
MobVistaConstans.API_REUQEST_CATEGORY_APP);
//preloadMap.put(MobVistaConstans.PROPERTIES_API_REUQEST_CATEGORY,
// MobVistaConstans.API_REUQEST_CATEGORY_GAME)
nativeHandle = new MvNativeHandler(properties, this);
nativeHandle.addTemplate(new Template(MobVistaConstans.TEMPLATE_BIG_IMG, 1));//The advertising support large image template
nativeHandle.addTemplate(new Template(MobVistaConstans.TEMPLATE_MULTIPLE_IMG, 1));// The slot supports multi-map template
nativeHandle.setAdListener(new NativeAdListener() {
@Override
public void onAdLoaded(List<Campaign> campaigns,int template) {
if(template == MobVistaConstans.TEMPLATE_BIG_IMG){
//The Big Picture template
}
Log.e("", "onAdLoaded");
}
@Override
public void onAdLoadError(String message) {
Log.e("", "onAdLoadError");
}
@Override
public void onAdClick(Campaign campaign) {
Log.e("", "onAdClick");
}
});
nativeHandle.setTrackingListener(new NativeTrackingListener() {
@Override
public void onStartRedirection(Campaign campaign, String url) {
// TODO Auto-generated method stub
}
@Override
public void onRedirectionFailed(Campaign campaign, String url) {
// TODO Auto-generated method stub
}
@Override
public void onFinishRedirection(Campaign campaign, String url) {
// TODO Auto-generated method stub
}
@Override
public void onDownloadStart(Campaign campaign) {
// TODO Auto-generated method stub
}
@Override
public void onDownloadFinish(Campaign campaign) {
// TODO Auto-generated method stub
}
//The back is used to show download progress
@Override
public void onDownloadProgress(int progress) {
// TODO Auto-generated method stub
}
});
//STEP3: Load native ad
nativeHandle.load();
//STEP4: when UI is ready, register your view to SDK and Let SDK to handle the tracking.
nativeHandle.registerView(btn2click,campaign);
//STEP5: release the nativeController
nativeAd.release();