Back to project page com.elsewhat.android.slideshow.
The source code is released under:
Copyright (C) 2012 Dagfinn Parnas <dagfinn.parnas@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Sof...
If you think the Android project com.elsewhat.android.slideshow listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.elsewhat.android.slideshow.api; // w ww . j a v a 2s. c o m import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.elsewhat.android.slideshow.activities.SlideshowPreferences; import com.google.android.apps.analytics.GoogleAnalyticsTracker; public class Analytics { //TODO-FORK: Add your own google analytics id public final static String ANALYTICS_ID = "UA-28244457-1"; private static GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker .getInstance(); private static boolean isStarted = false; public static void trackPageView(Context context, String pageName) { if (isEnabled(context)) { try { if (!isStarted) { tracker.startNewSession(Analytics.ANALYTICS_ID, 15, context); isStarted = true; } tracker.trackPageView(pageName); } catch (RuntimeException e) { Log.d("RedditTV", "Hmmm exception during analytics", e); } } } public static void trackEvent(Context context, String category, String name, String value) { if (isEnabled(context)) { try { if (!isStarted) { tracker.startNewSession(Analytics.ANALYTICS_ID, 15, context); isStarted = true; } // analytics don't like whitespace name = name.replaceAll(" ", ""); if (value == null) { value = "null"; } value = value.replaceAll(" ", ""); tracker.trackEvent(category, name, value, 0); } catch (RuntimeException e) { Log.d("RedditTV", "Hmmm exception during analytics", e); } } } public static boolean isEnabled(Context context) { SharedPreferences settings = context.getSharedPreferences( SlideshowPreferences.PREFS_NAME, 0); return settings.getBoolean(SlideshowPreferences.KEY_DO_ANALYTICS, false); } }