在libs里加上Flurry的jar包
可以写一个Flurry的管理类:
public class FlurryTypes {
public static final String DOWNLOAD_BOOK = "down load book";
public static final String BOOK_NAME = "book_name";
public static final String VIEW_AUTHOR = "view_author";
public static final String AUTHOR_NAME = "author_name";
public static final String VIEW_BOOK = "view_author";
public static final String DOWNLOAD_ERROR = "down_load_error";
public static final String CLECIK_MENU = "click_menu";
public static final String OPERTION = "operation";
public static final String AUTHOR_LIST = "author_list";
public static final String MY_FAV = "My_fav";
public static final String TURN_ON_PAGE = "turn on page_animation";
public static final String VOICE_TURN_ON = "voice turn on";
public static final String CHANGE_BACKGROUND = "change background";
public static final String FEEDBACK = "feed back";
public static final String SHARE = "share";
public static final String CHECK_UPDATE = "check update";
public static final String DELETE_FAVORITE = "delete favorite book";
public static final String DELETE_AUTHOR = "delete author";
public static final void onStartSession(Context context){
if (Global.ENABLE) {
try {
FlurryAgent.setUseHttps(false);
FlurryAgent.setCaptureUncaughtExceptions(true);
//这个是KEY
FlurryAgent.onStartSession(context, "ZJN9MZFDFQNZPFVHNJCX");
FlurryAgent.setLogEvents(true);
} catch (java.lang.Throwable t) {
}
}
}
public static final void onEndSession(Context context){
if (Global.ENABLE) {
try {
FlurryAgent.onEndSession(context);
} catch (java.lang.Throwable t) {
}
}
}
public static final void onEvent(String eventId){
if (Global.ENABLE) {
long currentTime = SystemClock.elapsedRealtime();
try {
Map params = new HashMap();
FlurryAgent.onEvent(eventId,params);
} catch (java.lang.Throwable t) {
}
}
}
public static final void onEventUseMap(String eventId, Map map) {
if (Global.ENABLE) {
try {
FlurryAgent.onEvent(eventId, map);
} catch (java.lang.Throwable t) {
}
}
}
public static final void onEvent(String eventId, String paramValue){
if (Global.ENABLE) {
try {
HashMap params = new HashMap();
params.put(eventId, paramValue);
FlurryAgent.onEvent(eventId, params);
} catch (java.lang.Throwable t) {
}
}
}
public static final void onEvent(String eventId, String paramKey, String paramValue){
if (Global.ENABLE) {
long currentTime = SystemClock.elapsedRealtime();
try {
Map params = new HashMap();
params.put(paramKey, paramValue);
FlurryAgent.onEvent(eventId, params);
} catch (java.lang.Throwable t) {
}
}
}
}
在每个Activity中:
@Override
protected void onStart() {
super.onStart();
FlurryTypes.onStartSession(this);
}
@Override
protected void onStop() {
super.onStop();
FlurryTypes.onEndSession(this);
}
调用可以这样来写:
FlurryTypes.onEvent(FlurryTypes.DELETE_AUTHOR, FlurryTypes.AUTHOR_NAME, info.name);
或是这样:
Map map = new HashMap();
map.put(FlurryTypes.BOOK_NAME, novelinfo.name);
map.put(FlurryTypes.AUTHOR_NAME, novelinfo.author);
FlurryTypes.onEventUseMap(FlurryTypes.DOWNLOAD_BOOK, map);
原文:http://blog.csdn.net/baidu_nod/article/details/38492457