1.建立程序,登陆https://mtj.baidu.com/web/welcome/login把自己的程序写入得到Key值
2.下载sdk得到统计的jar包
3.在程序中AndroidManifest.xml进行配置 如下:
android:name="BaiduMobAd_STAT_ID"
android:value="fba0de7cf2" />
android:name="BaiduMobAd_CHANNEL"
android:value="Baidu Market" />
android:name="BaiduMobAd_EXCEPTION_LOG"
android:value="true" />
android:name="BaiduMobAd_SEND_STRATEGY"
android:value="APP_START" />
android:name="BaiduMobAd_ONLY_WIFI"
android:value="false" />
android:name="BaiduMobAd_CELL_LOCATION"
android:value="true" />
android:name="BaiduMobAd_GPS_LOCATION"
android:value="true" />
android:name="BaiduMobAd_WIFI_LOCATION"
android:value="true" />
代码中:一般都在欢迎页面或者登陆页面
StatService.setSessionTimeOut(30);
StatService.setOn(this, StatService.EXCEPTION_LOG);
StatService.setLogSenderDelayed(0);
StatService.setSendLogStrategy(this, SendStrategyEnum.SET_TIME_INTERVAL, 1, false);
StatService.setDebugOn(true);//调试debug是用,上线的时候改成false
以上5个StatService都放在Oncreate()中
如果想要看用户点击的页面可以在每个Activity或者Fragment中添加以下代码即可:
/**
* 统计页面 所需要的两个方法
*/
@Override
protected void onResume() {
super.onResume();
StatService.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
StatService.onPause(this);
}