sdk/src/main/java/com/bugsnag/android/SessionTracker.java
void updateForegroundTracker(String activityName, boolean activityStarting, long nowMs) {
        if (activityStarting) {
            long noActivityRunningForMs = nowMs - activityLastStoppedAtMs.get();

            //FUTURE:SM Race condition between isEmpty and put
            if (foregroundActivities.isEmpty()
                && noActivityRunningForMs >= timeoutMs
                && configuration.shouldAutoCaptureSessions()) {

                activityFirstStartedAtMs.set(nowMs);
                startNewSession(new Date(nowMs), client.getUser(), true);
            }
            foregroundActivities.add(activityName);
        } else {
            foregroundActivities.remove(activityName);
            activityLastStoppedAtMs.set(nowMs);
        }
    }
/**
     * Tracks whether an activity is in the foreground or not.
     * <p>
     * If an activity leaves the foreground, a timeout should be recorded (e.g. 30s), during which
     * no new sessions should be automatically started.
     * <p>
     * If an activity comes to the foreground and is the only foreground activity, a new session
     * should be started, unless the app is within a timeout period.
     *
     * @param activityName     the activity name
     * @param activityStarting whether the activity is being started or not
     * @param nowMs            The current time in ms
     */
Tracks whether an activity is in the foreground or not.

If an activity leaves the foreground, a timeout should be recorded , during which
no new sessions should be automatically started.

If an activity comes to the foreground and is the only foreground activity, a new session
should be started, unless the app is within a timeout period.

@param activityName     the activity name
@param activityStarting whether the activity is being started or not
@param nowMs            The current time in ms
Tracks whether an activity is in the foreground or not . If an activity leaves the foreground a timeout should be recorded during which no new sessions should be automatically started . If an activity comes to the foreground and is the only foreground activity a new session should be started unless the app is within a timeout period . @param activityName the activity name @param activityStarting whether the activity is being started or not @param nowMs The current time in ms
void updateForegroundTracker(String activityName, boolean activityStarting, long nowMs) {
        if (activityStarting) {
            long noActivityRunningForMs = nowMs - activityLastStoppedAtMs.get();
            if (foregroundActivities.isEmpty()
                && noActivityRunningForMs >= timeoutMs
                && configuration.shouldAutoCaptureSessions()) {
                activityFirstStartedAtMs.set(nowMs);
                startNewSession(new Date(nowMs), client.getUser(), true);
            }
            foregroundActivities.add(activityName);
        } else {
            foregroundActivities.remove(activityName);
            activityLastStoppedAtMs.set(nowMs);
        }
    }
void updateForegroundTracker ( String activityName , boolean activityStarting , long nowMs ) { if ( activityStarting ) { long noActivityRunningForMs = nowMs - activityLastStoppedAtMs . get ( ) ; if ( foregroundActivities . isEmpty ( ) && noActivityRunningForMs >= timeoutMs && configuration . shouldAutoCaptureSessions ( ) ) { activityFirstStartedAtMs . set ( nowMs ) ; startNewSession ( new Date ( nowMs ) , client . getUser ( ) , true ) ; } foregroundActivities . add ( activityName ) ; } else { foregroundActivities . remove ( activityName ) ; activityLastStoppedAtMs . set ( nowMs ) ; } }
Tracks whether an activity is in the foreground or not.
Tracks whether an activity is in the foreground or not .
//FUTURE:SM Race condition between isEmpty and put