android一种统计工具Flurry的使用说明

Flurry的相关JAR包和文档:http://download.csdn.net/detail/baidu_nod/7739881

在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<String, String> params = new HashMap<String, String>();
				FlurryAgent.onEvent(eventId,params);
			} catch (java.lang.Throwable t) {
			}
		}
	}
	
	
	public static final void onEventUseMap(String eventId, Map<String, String> 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<String, String> params = new HashMap<String, String>();
				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<String, String> params = new HashMap<String, String>();
				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<String,String>();
				map.put(FlurryTypes.BOOK_NAME, novelinfo.name);
				map.put(FlurryTypes.AUTHOR_NAME, novelinfo.author);
				FlurryTypes.onEventUseMap(FlurryTypes.DOWNLOAD_BOOK, map);


android一种统计工具Flurry的使用说明,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。