I've implemented the TextToSpeech
integration exactly as mentioned in this blog post. After I've added it to my program it's now interfering with my other intent
s.
For example:
- List item
- User starts app
- User invokes load activity
- User picks a file to load, and activity returns fileanme to load in the intent
- Main activity starts, and realizes it needs to load a filename so it starts doing so
- The check for TTS needs to be done so I launch the
ACTION_CHECK_TTS_DATA
intent - This pauses the main activity again and the loading process gets interrupted
- When the TTS check returns, the loading never happened.
When do I need this TTS check? Can I just do it once on application start up? It's causing my application to load slowly. I would like this load to be performed in a separate thread if possible.
Do the check once. Once the data is installed, it's very unlikely that the user will need to ever do it again. Once the data is installed, there's no way for the user to delete it, even if they wanted to.
Also, don't use the ACTION_CHECK_TTS_DATA Intent, that's awkward to use.
Instead, do the following:
Here's some code that initializes a TextToSpeech in the way I suggest. As a bonus, it sets the language as well.