title: stop / shutdown failed: not bound to TTS engine
body: <p>I have an android activity that uses TTS but when I exit it get a leaked Service Connection error in Logcat.  Above the leaked Service error I get a statement that:</p>
  
  <pre><code>stop failed: not bound to TTS engine
  shutdown failed: not bound to TTS engine
  </code></pre>
  
  <p>My onStop and onDestroy look like this:
  EDIT Code:</p>
  
  <pre><code>@Override
  public void onStop() {
      if (tts != null) {
      tts.stop();
      }
      super.onStop();
  }
  
  @Override
  public void onDestroy() {
      if (tts != null) {
          tts.shutdown();
      }
      super.onDestroy();
  }
  </code></pre>
  
  <p>I trigger the TTS when the user pushes a button (TTS does work ok, I am just trying to fix the service connection error)</p>
  
  <pre><code>if (v == speakButton &amp;&amp; ttscrashprotect == 1) {   
      String text = inputText.getText().toString();
      if (text != null &amp;&amp; text.length() &gt; 0) {
          tts.speak(text, TextToSpeech.QUEUE_ADD, null);
      }
  </code></pre>
  
  <p>This is my onActivityResult</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == MY_DATA_CHECK_CODE) {
          if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
              //sucess with TTS create it
              tts = new TextToSpeech(this, this);
          }
          else {
              //missing TTS so install it
              Intent installIntent = new Intent();
              installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
              startActivity(installIntent);
          }
      }
  </code></pre>
  
  <p>TTS is working fine and I can see the engine being called in logcat, but for some reason the <code>tts.stop()</code> and <code>tts.shutdown()</code> aren't bound to the same engine.</p>
  
  <p>EDIT2:  It would seem I am connecting to the TTS engine and service more than one time.  Each time the text that I want TTS to say within the activity then another connection is made to the TTS engine and TTS service. </p>
  
  <p>My TTS code when the text changes looks like this:</p>
  
  <pre><code>if (v==nextButton &amp;&amp; progressL1&lt;100) {
      Video.setVisibility(View.INVISIBLE); //hide the video view
  
      progressL1= progressL1 + 10;
      //increase progress by 10 and then load the new files
      //load the TTS text data from Asset folder progressL1 txt file
      Advanced.this.loadDataFromAsset(progressL1);
      //try some tts stuff here
      Intent checkIntent = new Intent();
      checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
      startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
  </code></pre>
  
  <p>TTS is triggered from the <code>v == speakButton</code> code above.</p>