Search in sources :

Example 1 with SessionTracker

use of com.microsoft.appcenter.analytics.channel.SessionTracker in project mobile-center-sdk-android by Microsoft.

the class Analytics method applyEnabledState.

/**
 * React to enable state change.
 *
 * @param enabled current state.
 */
@Override
protected synchronized void applyEnabledState(boolean enabled) {
    /* Start session tracker when enabled. */
    if (enabled) {
        mSessionTracker = new SessionTracker(mChannel, ANALYTICS_GROUP);
        mChannel.addListener(mSessionTracker);
        if (mCurrentActivity != null) {
            Activity activity = mCurrentActivity.get();
            if (activity != null) {
                processOnResume(activity);
            }
        }
    } else /* Release resources if disabled and enabled before with resources. */
    if (mSessionTracker != null) {
        mChannel.removeListener(mSessionTracker);
        mSessionTracker.clearSessions();
        mSessionTracker = null;
    }
}
Also used : Activity(android.app.Activity) SessionTracker(com.microsoft.appcenter.analytics.channel.SessionTracker)

Aggregations

Activity (android.app.Activity)1 SessionTracker (com.microsoft.appcenter.analytics.channel.SessionTracker)1