The official introduction to Text-To-Speech in Android says that "upon creating your activity, a good first step is to check for the presence of the TTS resources with the corresponding intent:"
Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
But @gregm in this thread suggests otherwise:
Also, don't use the ACTION_CHECK_TTS_DATA Intent, that's awkward to use.
Instead, do the following:
- Create TextToSpeech
- OnInit, check isLanguageAvailable() if it is, your app is all set. if not, send the ACTION_INSTALL_TTS_DATA
If I understand correctly, what @gregm does/suggests is to defer the TextToSpeech.LANG_MISSING_DATA
check from onActivityResult()
to onInit()
.
Why is this better than the formal approach?
And why is ACTION_CHECK_TTS_DATA so "awkward to use"?