Search code examples
androidchronometer

Check if Chronometer is running


chronometer in android how to check whether chronometer is running or stop? if start then i want to stop it and if not running then start chronometer.


Solution

  • You can check this using boolean variable.when you start chronometer you set boolean variable true and when it stop you set boolean variable false.

    boolean isChronometerRunning = false;
    if (true)  // condition on which you check whether it's start or stop
    {
        chronometer.start();
        isChronometerRunning  = true;
    }
    else
    {
      chronometer.stop();
      isChronometerRunning  = false;
    }