title: Android Wait until Text to Speech OnInit is called
body: <p>I had an issue where Text to Speech would not speak anything.  I realised this was due to the fact that I was attempting to call 'Speak()' before TTS had initialised.</p>
  
  <p>I need to wait until TTS has initialised, so that I can call 'Speak()' successfully.  I thought doing something along the lines of this would work:</p>
  
  <pre><code>@Override
  public void onInit(int status) {
      if (status == TextToSpeech.SUCCESS) {
          mTTSInitialised = true;
      } else {
          Log.e("TTS", "Initialisation Failed!");
      }
  }
  
  ...
  
  while(!mTTSInitialised){
      try {
          Thread.sleep(1000);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>But this fails to initialise at all.  Is there a way to do this effectively?</p>