title: How to Start Incremental Timer in Android
body: <p>Before Asking Question let me tell you that this Question has been answered many time but I didn't resolve my problem.
  I tried <a href="https://stackoverflow.com/questions/4597690/android-timer-how">this Questions</a> Answer but not really helpful.</p>
  
  <p>So Problem is I am creating a Mastermind Game in android and I want to start the timer from 00:00 when user Enter the first PIN to so on until the user hit the Last PIN or When user Click on New Game Timer will Reset and will not start until User Enter the first PIN again.</p>
  
  <p>So here is my Try</p>
  
  <pre><code>Handler timerHandler = new Handler();
  Runnable timerRunnable = new Runnable() {
  
      @Override
      public void run() {
          long millis = System.currentTimeMillis() - startTime;
          int seconds = (int) (millis / 1000);
          int minutes = seconds / 60;
          seconds = seconds % 60;
  
          timerTextView.setText(String.format("%d:%02d", minutes, seconds));
  
          timerHandler.postDelayed(this, 500);
      }
  };
  </code></pre>
  
  <p>function to start or stop timer</p>
  
  <pre><code>@Override
  public void onPause() {
      super.onPause();
      timerHandler.removeCallbacks(timerRunnable);
      timerCheck = true;
  }
  </code></pre>
  
  <p>when user hit the first PIN this code execute</p>
  
  <pre><code>timerCheck = true;
  startTimer();
  </code></pre>
  
  <p>When user hit the Last PIN this Code Execute</p>
  
  <pre><code>timerCheck = false;
  startTimer();
  </code></pre>
  
  <p>Nothing is Working
  Please Help me To start Timer when First Condition is True and Stop Timer when Last Condition is true, in between if NewGame get Hit Timer will reset and don't start until First Pin got Hit again.
  Any help will be grateful.
  Thanks in Advance </p>