title: Android: Delay before onFinish() in CountDownTimer
body: <p>I was trying to create a simple Tap Counter app but i am getting a noticeable lag at the end before it moves to the onFinish(), giving user a couple of extra taps before stopping the counter.</p>
  
  <p>Here is the MainActivity.java</p>
  
  <pre><code>package com.example.tapcounter;
  
  import android.os.Bundle;
  import android.os.CountDownTimer;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  import android.app.Activity;
  
  public class MainActivity extends Activity
  {
  TextView time;
  TextView taps;
  Button b;
  
  int flag = 0;
  int count = 0, finalTap = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      time = (TextView) findViewById(R.id.textView1);
      taps = (TextView) findViewById(R.id.textView2);
      b = (Button) findViewById(R.id.button1);
  
      b.setOnClickListener(new OnClickListener() 
      {
  
          @Override
          public void onClick(View arg0) 
          {
              if(finalTap==0)
              {
                  if(flag==0)
                  {
                      beginTimer();
                      flag=1;
                  }
                  updateCount();
              }
          }
      });
  }
  
  private void beginTimer()
  {
      new CountDownTimer(10000, 1000) 
      {
  
          public void onTick(long millisUntilFinished) 
          {
              time.setText("Time: "+millisUntilFinished/1000);
          }
  
          public void onFinish() 
          {
              time.setText("Timeout!!!");
              finalTap++;
          }
      }.start();  
  }
  
  private void updateCount()
  {
      taps.setText("Taps: " + Integer.toString(++count));
  }
  }
  </code></pre>