I am developing a very simple app in here. It\'s for my Cerebral Palsy daughter. It\'s just a big YES and NO buttons, so she can press them when requested.
Well... I am
This is what I have in onActivityResult(...)
@Override
protected void onActivityResult(
int requestCode, int resultCode, Intent data) {
if (requestCode == MY_DATA_CHECK_CODE) {
/*
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
// success, create the TTS instance
mTts = new TextToSpeech(this, this);
} else {
// missing data, install it
Intent installIntent = new Intent();
installIntent.setAction(
TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
*/
if (mTts==null) {
Intent installIntent = new Intent();
installIntent.setAction(
TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
mTts = new TextToSpeech(this, this);
}
}
Instead of using if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {...}
, I check if mTts
has already been instantiated. You'll also have to set mTts
as static
, as was mentioned by jlquant and Rakesh in an earlier post, so you'll have only a single instance of it. For example, private static TextToSpeech mTts
.
So, unless you "Force stop" the app or it stops working because of an error, it won't anymore call the startActivity(installIntent);
-- the annoying culprit that asks you to install TTS every time.