Search code examples
androidtext-to-speech

Text to speech pattern in Android


I'm trying to use TextToSpeech in my app.

I wrote it as a bound service. Problem appears when I need to read text before activity stops. It says just half of text because activity calls unbind and finish itself.

What is better pattern to write Text to speech if I dont want write it direct into actvivity?


Solution

  • Instead of just bind service, start your service using startService() and then bind. After reading the text in onUtteranceCompleted() call stopSelf().