title: What is wrong with my Text-To-Speech in my CountDownTimer?
body: <p>Hey all, I'm trying to put text-to-speech in my CountDownTimer. I would like it to say "There are x seconds left" after a certain amount of time. I just started using TextToSpeech and I'm not really sure what I'm doing..</p>
  
  <pre><code>    package com.android.countdown;
  
  
  import java.util.Locale;
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.CountDownTimer;
  import android.view.View;
  import android.speech.tts.TextToSpeech;
  import android.widget.Button;
  import android.widget.TextView;
  import android.view.View.OnClickListener;
  
  public class countdown extends Activity implements TextToSpeech.OnInitListener{
   CountDownTimer Counter1;
   CountDownTimer Counter2;
   CountDownTimer Counter3;
   int Interval = 1;
   TextToSpeech tts;
  
      public String formatTime(long millis) {
            String output = "0:00";
            long seconds = millis / 1000;
            long minutes = seconds / 60;
  
            seconds = seconds % 60;
            minutes = minutes % 60;
  
  
            String secondsD = String.valueOf(seconds);
            String minutesD = String.valueOf(minutes);
  
            if (seconds &lt; 10)
              secondsD = "0" + seconds;
            if (minutes &lt; 10)
              minutesD = "0" + minutes;
  
            output = minutesD + " : " + secondsD;
            return output;
          }
  
     @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
  
  
  
  
  //Declare Start/Stop timer
   Button btnstart = (Button)findViewById(R.id.btnstart);
   Button btnstop = (Button)findViewById(R.id.btnstop);
  
  //Text field to show time left
   final TextView mCounter1TextField=(TextView)findViewById(R.id.counter1);
   final TextView mCounter2TextField = (TextView)findViewById(R.id.counter2);
   final TextView mCounter3TextField=(TextView)findViewById(R.id.counter3);
  
  
  
  //Counter 1
  Counter1 = new CountDownTimer(20000 , Interval) {
  public void onTick(long millisUntilFinished){
      mCounter1TextField.setText("Seconds left: " + formatTime(millisUntilFinished));
      if (millisUntilFinished == 10000) {
       instantiate();
      }
  
  
  }
  
  public void onFinish() {
      Counter1.start();  
  }
  };
  
  //Counter 2
  Counter2 = new CountDownTimer(80000 , Interval) {
   public void onTick(long millisUntilFinished) {
       mCounter2TextField.setText("Seconds left: " + formatTime(millisUntilFinished));
  
   }
  
   public void onFinish() {
       mCounter2TextField.setText("Finished!");
       Counter2.start();
   }
   };
  
  //Counter 3
  Counter3 = new CountDownTimer(3000 , Interval) {
    public void onTick(long millisUntilFinished) {
        mCounter3TextField.setText("Seconds left: " + formatTime(millisUntilFinished));
    }
  
    public void onFinish() {
      mCounter3TextField.setText("Finished!");
      Counter3.start();
    }
    };
  
  
  //Start Button
  btnstart.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
    Counter1.start();
    Counter2.start();
    Counter3.start();
     }
  });
  
  //Stop Button
  btnstop.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
    Counter1.cancel();
    Counter2.cancel();
    Counter3.cancel();
    if (tts != null) {
    tts.stop();
          tts.shutdown();
    }
      }
  });
  }
  
     public void instantiate() {
        tts = new TextToSpeech(this, this);
        tts.setLanguage(Locale.US);
           tts.speak("You have 10 seconds remaining", TextToSpeech.QUEUE_ADD, null);
  
     }
  
   @Override
   public void onInit(int status) {
  
   }
  
      @Override
      public void onDestroy() {
          // Don't forget to shutdown!
          if (tts != null) {
              tts.stop();
              tts.shutdown();
          }
  
          super.onDestroy();
      }
  
  
  }
  </code></pre>