Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.os.SystemClock; public class Main { private static long sForegroundStartTimeMs; private static long sBackgroundTimeMs; /** * Record the time at which Chrome was brought to foreground. */ public static void recordForegroundStartTime() { // Since this can be called from multiple places (e.g. ChromeActivitySessionTracker // and FirstRunActivity), only set the time if it hasn't been set previously or if // Chrome has been sent to background since the last foreground time. if (sForegroundStartTimeMs == 0 || sForegroundStartTimeMs < sBackgroundTimeMs) { sForegroundStartTimeMs = SystemClock.uptimeMillis(); } } }