use of com.microsoft.azure.mobile.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.
*/
private synchronized void applyEnabledState(boolean enabled) {
/* Delayed initialization once channel ready and enabled (both conditions). */
if (enabled && mChannel != null && mSessionTracker == null) {
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 (!enabled && mSessionTracker != null) {
mChannel.removeListener(mSessionTracker);
mSessionTracker.clearSessions();
mSessionTracker = null;
}
}
Aggregations