title: The Countdown Timer in Android studio skips some of the seconds within the time interval
body: <p>I read about the problem a day ago where the problem occurs with people but when it comes to the final second. I kept noticing in my timer that the as it counts down it sometimes skips a second, some suggested changing the interval from 1000ms to 500ms others said make it 900. And there are those who suggested making your own Timer.</p>
  <p>My timer is a bit big as it contains two smaller timers within it, that count down individual minutes within the total time and I activate an animation during those times. So basically I am asking what approach should I take to for a time critical counter that is 100% accurate?</p>
  <p>This is my code:</p>
  <pre><code>        private void startTimer() {
          Log.println(Log.ASSERT, &quot;CHECK&quot;,&quot;Entered startTimer() method&quot;);
          millisInFuture = mTimeLeftInMillis;
          mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 900) {
              @Override
              public void onTick(long millisUntilFinished) {
                  mTimeLeftInMillis = millisUntilFinished;
                  updateCountDownText();
                  millisPassed = millisInFuture - mTimeLeftInMillis;
                  progress = (int) (millisPassed * 100 / millisInFuture);
                  pb.setProgress(progress);
                  pb2.setProgress(0);
                  pb3.setProgress(0);
  
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                  //Key: 60 sec
                  if (millisInFuture == 480000) {
                      if (millisPassed &lt;= 60000 || (millisPassed &gt; 180000 &amp;&amp; millisPassed &lt;= 240000) || (millisPassed &gt; 300000 &amp;&amp; millisPassed &lt;= 360000 || (millisPassed &gt; 420000 &amp;&amp; millisPassed &lt;= 480000))) {
  //                        Animation animation = AnimationUtils.loadAnimation(tool1mode1.this, R.anim.fade_in);
  //                        stepupimage.setAnimation(animation);
  
                          Log.println(Log.ASSERT,&quot;CHECK&quot;,&quot;Check that the first if statement of key 60 is entered&quot;);
                          statusIfUp();
                          time_of_stage = (millisInFuture - millisPassed) % 60000;
                          progress2 = (int) (time_of_stage*100 / 60000);
                          Log.println(Log.VERBOSE,&quot;CHECK&quot;,&quot;TIME OF STAGE = &quot;+time_of_stage);
                          Log.println(Log.VERBOSE,&quot;CHECK&quot;,&quot;progress2= &quot;+progress2);
                          pb2.setProgress(progress2);
                          updateStageUpCount();
                          upArrowAnimation();
  
                          setflowrate();
  }
  }
      @Override
              public void onFinish() {
                  Toast.makeText(tool1mode1.this, &quot;Done&quot;, Toast.LENGTH_SHORT).show();
                  avd2.stop(); avd3.stop();
                  try {
                  pb.setProgress(100); pb2.setProgress(0); pb3.setProgress(0);
                  stage_timer.setVisibility(View.INVISIBLE);
                  stage_timer.setVisibility(View.INVISIBLE);
                  progressBar.setVisibility(View.INVISIBLE);
                  progressBar2.setVisibility(View.INVISIBLE);
                  progressBar.setProgress(0);
                  progressBar2.setProgress(0);
                  progressBar.setTranslationY(60);
                  progressBar2.setTranslationY(60);
                  flow.setTranslationY(60);
                  animation1.cancel(); animation2.cancel();
                  //Vibration
  
  
                      if (Build.VERSION.SDK_INT &gt;= 26) {
                          ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(150, VibrationEffect.DEFAULT_AMPLITUDE));
                      } else {
                          ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createWaveform(new long[]{150}, new int[]{VibrationEffect.EFFECT_CLICK}, -1));
                      }
                  }
                  catch (NullPointerException e) {
                      e.printStackTrace();
                  }
  
              }
          }.start();
  
      }
  </code></pre>
  <p>So to summarize: I have  a big timer and two small timers that count certain intervals within the larger timer. Now the <em>CountDownTimer</em> class that is provided by Android skips a second or two at times during the count down. I want to fix this problem and don't know how, I would have just rolled with it but unfortunately the one I'm making the app for requires it to be 100% accurate as the application is time critical.</p>
  <p>Note: pb, pb2, pb3, are progress bars of the timers (1st is the big one, 2nd and 3rd alternate for the second timer)</p>