title: Running Android TTS in a Service
body: <p>I'm trying to get Android's TTS to run inside a service, but I have no idea why it isn't working, it compiles, doesn't crash, but it just doesn't work.</p>
  
  <p>The Toast notification do work though.</p>
  
  <pre><code>package alarm.test;
  
  import android.app.Service;
  import com.google.tts.TextToSpeechBeta;
  import android.content.Intent;
  import android.os.IBinder;
  import android.widget.Toast;
  
  public class MyAlarmService extends Service {
  
      private TextToSpeechBeta myTts;
      private TextToSpeechBeta.OnInitListener ttsInitListener = new TextToSpeechBeta.OnInitListener() {
          public void onInit( int arg0, int arg1 ) {
              myTts.speak("", 0, null);
          }
      };
  
  @Override
  public void onCreate() {
   // TODO Auto-generated method stub
      myTts = new TextToSpeechBeta( this,
              ttsInitListener );
  
   Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG).show();
  }
  
  @Override
  public IBinder onBind(Intent intent) {
   // TODO Auto-generated method stub
      myTts.speak("something is working", TextToSpeechBeta.QUEUE_FLUSH, null);
   Toast.makeText(this, "MyAlarmService.onBind()", Toast.LENGTH_LONG).show();
   return null;
  }
  
  @Override
  public void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG).show();
  }
  
  @Override
  public void onStart(Intent intent, int startId) {
   // TODO Auto-generated method stub
   super.onStart(intent, startId);
   Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show();
  }
  
  @Override
  public boolean onUnbind(Intent intent) {
   // TODO Auto-generated method stub
   Toast.makeText(this, "MyAlarmService.onUnbind()", Toast.LENGTH_LONG).show();
   return super.onUnbind(intent);
  }
  
  }
  </code></pre>