Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android一種統計工具Flurry的使用說明

android一種統計工具Flurry的使用說明

編輯:關於Android編程

 

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


 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved