Code example for Chronometer

Methods: setBase, start

0
    } 
 
    public synchronized void start() { 
        if (!isPlayTimeRunning) {
            long passedPlayTime = SystemClock.elapsedRealtime() - playTime;
            playTimer.setBase(passedPlayTime);
            startEffectiveTime(); 
            playTimer.start();
            isPlayTimeRunning = true;
        } 
    } 
 
    public synchronized void stop() { 
        if (isPlayTimeRunning) {
            playTime = SystemClock.elapsedRealtime() - playTimer.getBase();
            stopEffectiveTime(); 
            playTimer.stop();
            isPlayTimeRunning = false;
        } 
    }