title: Android: How to pause and resume a Count Down Timer?
body: <p>I have developed a Count Down Timer and I am not sure how to pause and resume the timer as the textview for the timer is being clicked. Click to start then click again to pause and to resume, click again the timer's text view.</p>
  
  <p>This is my code:</p>
  
  <pre><code>    Timer = (TextView) this.findViewById(R.id.time); //TIMER  
      Timer.setOnClickListener(TimerClickListener);
      counter = new MyCount(600000, 1000);
  }//end of create 
  
  private OnClickListener TimerClickListener = new OnClickListener() {
      public void onClick(View v) {
          updateTimeTask();
      }
  
      private void updateTimeTask() {
          if (decision == 0) {
              counter.start();
              decision = 1;
          } else if (decision == 2) {
              counter.onResume1();
              decision = 1;
          } else {
              counter.onPause1();
              decision = 2;
          }//end if  
      }
  
      ;
  };
  
  class MyCount extends CountDownTimer {
      public MyCount(long millisInFuture, long countDownInterval) {
          super(millisInFuture, countDownInterval);
      }//MyCount  
  
      public void onResume1() {
          onResume();
      }
  
      public void onPause1() {
          onPause();
      }
  
      public void onFinish() {
          Timer.setText("00:00");
          p1++;
          if (p1 &lt;= 4) {
              TextView PScore = (TextView) findViewById(R.id.pscore);
              PScore.setText(p1 + "");
          }//end if  
      }//finish  
  
      public void onTick(long millisUntilFinished) {
          Integer milisec = new Integer(new Double(millisUntilFinished).intValue());
          Integer cd_secs = milisec / 1000;
  
          Integer minutes = (cd_secs % 3600) / 60;
          Integer seconds = (cd_secs % 3600) % 60;
  
          Timer.setText(String.format("%02d", minutes) + ":"
                  + String.format("%02d", seconds));
          ///long timeLeft = millisUntilFinished / 1000;  
          /}//on tick  
  }//class MyCount  
  
  protected void onResume() {
      super.onResume();
      //handler.removeCallbacks(updateTimeTask);  
      //handler.postDelayed(updateTimeTask, 1000);  
  }//onResume  
  
  @Override
  protected void onPause() {
      super.onPause();
      //do stuff  
  }//onPause  
  </code></pre>