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);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值