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

來源:互聯網
上載者:User

標籤: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);//這個是KEYFlurryAgent.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中:

@Overrideprotected void onStart() {super.onStart();FlurryTypes.onStartSession(this);}@Overrideprotected 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);


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.