Java 类com.google.android.gms.analytics.GoogleAnalytics 实例源码

项目:iosched-reader    文件:AnalyticsHelper.java   
/**
 * Initialize the analytics tracker in use by the application. This should only be called
 * once, when the TOS is signed. The {@code applicationContext} parameter MUST be the
 * application context or an object leak could occur.
 */
private static synchronized void initializeAnalyticsTracker(Context applicationContext) {
    sAppContext = applicationContext;
    if (mTracker == null) {
        int useProfile;
        if (BuildConfig.DEBUG) {
            LOGD(TAG, "Analytics manager using DEBUG ANALYTICS PROFILE.");
            useProfile = R.xml.analytics_debug;
        } else {
            useProfile = R.xml.analytics_release;
        }

        try {
            mTracker = GoogleAnalytics.getInstance(applicationContext).newTracker(useProfile);
        } catch (Exception e) {
            // If anything goes wrong, force an opt-out of tracking. It's better to accidentally
            // protect privacy than accidentally collect data.
            setAnalyticsEnabled(false);
        }
    }
}
项目:microbit    文件:HomeActivity.java   
/**
 * Allows to turn on/off sharing statistics ability.
 */
private void toggleShareStatistics() {
    if(mShareStatsCheckBox == null) {
        return;
    }
    boolean shareStatistics = mShareStatsCheckBox.isChecked();

    if(shareStatistics) {
        GoogleAnalytics.getInstance(this).reportActivityStart(this);
    } else {
        GoogleAnalytics.getInstance(this).reportActivityStop(this);
    }

    mPrefs.edit().putBoolean(getString(R.string.prefs_share_stats_status), shareStatistics).apply();
    logi("shareStatistics = " + shareStatistics);
    GoogleAnalyticsManager.getInstance().setShareStatistic(shareStatistics);
    GoogleAnalyticsManager.getInstance().
            sendStatSharing(HomeActivity.class.getSimpleName(), shareStatistics);
}
项目:smconf-android    文件:AnalyticsHelper.java   
/**
 * Initialize the analytics tracker in use by the application. This should only be called
 * once, when the TOS is signed. The {@code applicationContext} parameter MUST be the
 * application context or an object leak could occur.
 */
private static synchronized void initializeAnalyticsTracker(Context applicationContext) {
    sAppContext = applicationContext;
    if (mTracker == null) {
        int useProfile;
        if (BuildConfig.DEBUG) {
            LOGD(TAG, "Analytics manager using DEBUG ANALYTICS PROFILE.");
            useProfile = R.xml.analytics_debug;
        } else {
            useProfile = R.xml.analytics_release;
        }

        try {
            mTracker = GoogleAnalytics.getInstance(applicationContext).newTracker(useProfile);
        } catch (Exception e) {
            // If anything goes wrong, force an opt-out of tracking. It's better to accidentally
            // protect privacy than accidentally collect data.
            setAnalyticsEnabled(false);
        }
    }
}
项目:droidplanner-master    文件:GAUtils.java   
public static void initGATracker(DroidPlannerApp app) {
    if (sAppTracker == null) {
        final Context context = app.getApplicationContext();

        final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);

        // Call is needed for now to allow dispatching of auto activity
        // reports
        // (http://stackoverflow.com/a/23256722/1088814)
        analytics.enableAutoActivityReports(app);

        analytics.setAppOptOut(!new DroidPlannerPrefs(context).isUsageStatisticsEnabled());

        // If we're in debug mode, set log level to verbose.
        if (BuildConfig.DEBUG) {
            analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        }

        sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker);
    }
}
项目:base_app_android    文件:BaseApp.java   
private void initGoogleAnalytics() {
        analytics = GoogleAnalytics.getInstance(this);

        if(BuildConfig.DEBUG) {
            // true = for log output, it does not sent data to Google Analytics
            analytics.setDryRun(true);
            // To enable debug logging on a device run:
            // adb shell setprop log.tag.GAv4 DEBUG
            // adb logcat -s GAv4
            // true = disable google analytics on the app
//        analytics.setAppOptOut(true);
        }

        tracker = analytics.newTracker(getString(R.string.ga_trackingId));
        tracker.enableExceptionReporting(true);
        tracker.enableAdvertisingIdCollection(true);
        tracker.enableAutoActivityTracking(false);
    }
项目:ADAL    文件:AnalyticsManager.java   
/**
 * Gets the google analytics tracker.
 *
 * @return the google analytics tracker.
 */
private Tracker getTracker() {
    if (mTracker == null) {

        int checkExistence = mContext.getResources().getIdentifier("global_tracker", "xml", mContext.getPackageName());

        if (checkExistence == 0) {
            Log.e(AnalyticsManager.class.getCanonicalName(), "Please check if you have global-services.json");
        } else {
            mTracker = GoogleAnalytics.getInstance(mContext).newTracker(checkExistence);
            mTracker.enableAutoActivityTracking(false);
            mTracker.enableAdvertisingIdCollection(false);
            mTracker.enableExceptionReporting(false);
        }
    }
    return mTracker;
}
项目:UofT-Timetable    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
    if (!mTrackers.containsKey(target)) {
        Tracker tracker;
        switch (target) {
            case APP:
                tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
                tracker.enableAdvertisingIdCollection(true);
                break;

            default:
                throw new IllegalArgumentException("Unhandled analytics target " + target);
        }
        mTrackers.put(target, tracker);
    }

    return mTrackers.get(target);
}
项目:Tower-develop    文件:GAUtils.java   
public static void initGATracker(DroidPlannerApp app) {
    if (sAppTracker == null) {
        final Context context = app.getApplicationContext();

        final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);

        // Call is needed for now to allow dispatching of auto activity reports
        // (http://stackoverflow.com/a/23256722/1088814)
        analytics.enableAutoActivityReports(app);

        analytics.setAppOptOut(!DroidPlannerPrefs.getInstance(context).isUsageStatisticsEnabled());

        // If we're in debug mode, set log level to verbose.
        if (BuildConfig.DEBUG) {
            analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        }

        sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker);
    }
}
项目:2015-Google-I-O-app    文件:AnalyticsHelper.java   
/**
 * Initialize the analytics tracker in use by the application. This should only be called
 * once, when the TOS is signed. The {@code applicationContext} parameter MUST be the
 * application context or an object leak could occur.
 */
private static synchronized void initializeAnalyticsTracker(Context applicationContext) {
    sAppContext = applicationContext;
    if (mTracker == null) {
        int useProfile;
        if (BuildConfig.DEBUG) {
            LOGD(TAG, "Analytics manager using DEBUG ANALYTICS PROFILE.");
            useProfile = R.xml.analytics_debug;
        } else {
            useProfile = R.xml.analytics_release;
        }

        try {
            mTracker = GoogleAnalytics.getInstance(applicationContext).newTracker(useProfile);
        } catch (Exception e) {
            // If anything goes wrong, force an opt-out of tracking. It's better to accidentally
            // protect privacy than accidentally collect data.
            setAnalyticsEnabled(false);
        }
    }
}
项目:droidplanner-master    文件:GAUtils.java   
public static void initGATracker(DroidPlannerApp app) {
    if (sAppTracker == null) {
        final Context context = app.getApplicationContext();

        final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);

        // Call is needed for now to allow dispatching of auto activity reports
        // (http://stackoverflow.com/a/23256722/1088814)
        analytics.enableAutoActivityReports(app);

        analytics.setAppOptOut(!new DroidPlannerPrefs(context).isUsageStatisticsEnabled());

        // If we're in debug mode, set log level to verbose.
        if (BuildConfig.DEBUG) {
            analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        }

        sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker);
    }
}
项目:showroom-android    文件:ShowroomApplication.java   
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // Чтобы включить ведение журнала отладки, используйте adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker("global_tracker");
    }
    return mTracker;
}
项目:Canvas-Vision    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
    if (!mTrackers.containsKey(target)) {
        Tracker tracker;
        switch (target) {
            case APP:
                tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
                break;
            default:
                throw new IllegalArgumentException("Unhandled analytics target " + target);
        }
        mTrackers.put(target, tracker);
    }

    return mTrackers.get(target);
}
项目:sa-android    文件:SAGlobal.java   
synchronized static Tracker getGATracker(Context context) {
    if (tracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
        tracker = analytics.newTracker(R.xml.ga_app_tracker);
    }
    return tracker;
}
项目:Ships    文件:Analytics.java   
public void init(final Context context){
    if (tracker==null) {
           if (context==null){
               throw new IllegalArgumentException("No context set.");
           }
        // Create new tracker
        final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
        analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
        tracker = analytics.newTracker(R.xml.analytics);
    }
}
项目:Sprog-App    文件:SprogApplication.java   
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.app_tracker);
    }
    return mTracker;
}
项目:android-analytics    文件:TrackerManager.java   
synchronized private Tracker getDefaultTracker(Context context) {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
        mTracker = analytics.newTracker(mGaConfigLocation);
    }
    return mTracker;
}
项目:IdealMedia    文件:NavigationActivity.java   
public synchronized Tracker getTracker(TrackerName trackerId) {
    if (!mTrackers.containsKey(trackerId)) {

        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        Tracker t = analytics.newTracker(R.xml.global_tracker);
        mTrackers.put(trackerId, t);

    }
    return mTrackers.get(trackerId);
}
项目:mobsoft-lab    文件:MobSoftApplication.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    return mTracker;
}
项目:iosched-reader    文件:AnalyticsHelper.java   
/**
 * Enables or disables Analytics.
 * @param enableAnalytics Whether analytics should be enabled.
 */
private static void setAnalyticsEnabled(boolean enableAnalytics) {
    GoogleAnalytics instance  = GoogleAnalytics.getInstance(sAppContext);
    if (instance != null) {
        instance.setAppOptOut(!enableAnalytics);
        LOGD(TAG, "Analytics enabled: " + enableAnalytics);
    }

}
项目:PlusGram    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
  if (!mTrackers.containsKey(target)) {
    Tracker tracker;
    switch (target) {
      case APP:
        tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
        break;
      default:
        throw new IllegalArgumentException("Unhandled analytics target " + target);
    }
    mTrackers.put(target, tracker);
  }

  return mTrackers.get(target);
}
项目:PlusGram    文件:AnalyticsTrackers.java   
synchronized public Tracker getDefaultTracker() {
  if (mTracker == null) {
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext);
    // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
    mTracker = analytics.newTracker(R.xml.app_tracker);
  }
  return mTracker;
}
项目:CustomAndroidOneSheeld    文件:OneSheeldApplication.java   
public synchronized Tracker getTracker() {
    if (gaTracker != null)
        return gaTracker;
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
    analytics.setAppOptOut(isDebuggable);
    if (isDebuggable)
        analytics.getLogger().setLogLevel(LogLevel.VERBOSE);
    gaTracker = analytics.newTracker(ApiObjects.analytics
            .get("property_id"));
    gaTracker.enableAdvertisingIdCollection(true);
    gaTracker.setSessionTimeout(-1);
    return gaTracker;
}
项目:Lunary-Ethereum-Wallet    文件:AnalyticsApplication.java   
synchronized public void track(String s) {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    mTracker.setScreenName(s);
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
项目:Lunary-Ethereum-Wallet    文件:AnalyticsApplication.java   
public void event(String s) {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    mTracker.send(new HitBuilders.EventBuilder()
            .setCategory("Action")
            .setAction(s)
            .build());
}
项目:Pocket-Plays-for-Twitch    文件:PocketPlaysApplication.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        mTracker = analytics.newTracker(R.xml.global_tracker);
        mTracker.enableAdvertisingIdCollection(true);
    }

    return mTracker;
}
项目:Pocket-Plays-for-Twitch    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
  if (!mTrackers.containsKey(target)) {
    Tracker tracker;
    switch (target) {
      case APP:
        tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
        break;
      default:
        throw new IllegalArgumentException("Unhandled analytics target " + target);
    }
    mTrackers.put(target, tracker);
  }

  return mTrackers.get(target);
}
项目:Rey-MusicPlayer    文件:Common.java   
public void trackScreenView(String screenName) {
    Tracker t = getGoogleAnalyticsTracker();
    // Set screen name.
    t.setScreenName(screenName);
    // Send a screen view.
    t.send(new HitBuilders.ScreenViewBuilder().build());
    GoogleAnalytics.getInstance(this).dispatchLocalHits();
}
项目:Rey-MusicPlayer    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
    if (!mTrackers.containsKey(target)) {
        Tracker tracker;
        switch (target) {
            case APP:
                tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
                break;
            default:
                throw new IllegalArgumentException("Unhandled analytics target " + target);
        }
        mTrackers.put(target, tracker);
    }
    return mTrackers.get(target);
}
项目:VideoDownloader-Android    文件:AnalyticsTrackers.java   
public synchronized Tracker get(Target target) {
    if (!mTrackers.containsKey(target)) {
        Tracker tracker;
        switch (target) {
            case APP:
                tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
                break;
            default:
                throw new IllegalArgumentException("Unhandled analytics target " + target);
        }
        mTrackers.put(target, tracker);
    }

    return mTrackers.get(target);
}
项目:CoolApk-Console    文件:App.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    return mTracker;
}
项目:MangoBloggerAndroidApp    文件:MangoBlogger.java   
private void initGoogleAnalytics() {
    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800);

    tracker = analytics.newTracker("UA-106256858-1"); // Replace with actual tracker id
    tracker.enableExceptionReporting(true);
    tracker.enableAdvertisingIdCollection(true);
    tracker.enableAutoActivityTracking(true);
}
项目:FicsaveMiddleware    文件:FicsaveMiddlewareApplication.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 *
 * @return tracker
 */
public synchronized Tracker getDefaultGATracker() {
    if (mGTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        mGTracker = analytics.newTracker(R.xml.global_tracker);
        mGTracker.enableAdvertisingIdCollection(true);
        mGTracker.enableExceptionReporting(true);
    }
    return mGTracker;
}
项目:skeletoid-googleanalytics    文件:GAAppender.java   
@Override
public void enableAppender(Context context) {
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);

    //This can be configured via XML or code. Since we need to maintain this code on the lib, it must
    // be via xml (dummy file) that will ne replaced by the apps real file
    // examples of both configurations are available: https://developers.google.com/analytics/devguides/collection/android/v4/advanced
    mTracker = analytics.newTracker(mConfigurationFileId);
}
项目:BlogBookApp    文件:BlogBookAnalytics.java   
public void init(Context context, boolean optOut) {
    GoogleAnalytics ga = GoogleAnalytics.getInstance(context);
    ga.setAppOptOut(optOut);

    if (!optOut) {
        // Initializing the google analytics
        this.mTracker = ga.newTracker(R.xml.app_tracker);
        // Initializing the mixpanelapi analytics
        this.mMixpanelAPI = MixpanelAPI.getInstance(context, "0f9f5280a4fb76478215544e42fa1299");
    }
}
项目:DereHelper    文件:LIVE.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
    if (mTracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
    }
    return mTracker;
}
项目:PixelDungeonTC    文件:AndroidLauncher.java   
synchronized public Tracker getDefaultTracker()
{
    if (mTracker == null)
    {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        mTracker = analytics.newTracker(R.xml.global_tracker);
        mTracker.enableAutoActivityTracking(true);
        mTracker.enableExceptionReporting(true);
    }
    return mTracker;
}
项目:analitica    文件:GoogleAnalyticsHelper.java   
GoogleAnalyticsHelper(Context context, boolean enable, GoogleAnalyticsServiceIdentifier serviceIdentifier) throws AnalyticsInstantiationException {
    super(context, enable, serviceIdentifier);
    enabled = enable;
    if (enable && tracker == null) {
        tracker = GoogleAnalytics.getInstance(context).newTracker(serviceIdentifier.getTrackingId());
    }
}
项目:E621Mobile    文件:E621Application.java   
synchronized Tracker getTracker()
{
    TrackerName trackerId = TrackerName.APP_TRACKER;

    if (!mTrackers.containsKey(trackerId))
    {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        Tracker t = analytics.newTracker("UA-55342416-1");
        mTrackers.put(trackerId, t);
    }

    return mTrackers.get(trackerId);
}
项目:fitTimer    文件:FitTimerApplication.java   
/**
 * Gets the default {@link Tracker} for this {@link Application}.
 * @return tracker
 */
synchronized public Tracker getDefaultTracker() {
  if (mTracker == null) {
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
    mTracker = analytics.newTracker(R.xml.app_tracker);
  }
  return mTracker;
}
项目:android-rss-feed-reader    文件:RssFeedReaderApp.java   
@Override
public void onCreate() {
    sInstance = this;
    super.onCreate();
    MultiDex.install(this);

    GoogleAnalytics analytics = GoogleAnalytics.getInstance(getApplicationContext());
    mTracker = analytics.newTracker(R.xml.global_tracker);

    mAppComponent = DaggerAppComponent.builder()
            .appModule(new AppModule(this))
            .build();

    HockeyAppUtils.checkForCrashes(this);
}