I can't get my onUtteranceCompleted()
get fired on my Galaxy Nexus 4.0.2.
My emulators with api 8, 10 and 15 do fire onUtteranceCompleted()
.
edit: well.. the statement above is true for most cases, I just got it to work on my Hardware 4.0.2. Then I closed it and started it again, and onUtteranceCompleted() did not get fired again. Had the same thing yesterday (before some code changes), so it's not working 90% of the time. Can't figure it out ;(
edit2:FYI: the mTts.setOnUtteranceCompletedListener(this); returns TextToSpeech.SUCCESS
Here is my code:
(...)
public void onInit(int status) {
mTts.setOnUtteranceCompletedListener(this);
if (status == TextToSpeech.SUCCESS) {
int result = mTts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA ||
result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e(TAG, "Language is not available.");
} else {
TTSAusgabe.setEnabled(true);
}
} else {
Log.e(TAG, "TTS failed");
}
}
SayText() { (....)
MundAnimation.start();
HashMap<String, String> params = new HashMap<String, String>();
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "utterance");
mTts.speak("Ma Text", TextToSpeech.QUEUE_FLUSH, params);
}
}
// That's the bad boy!
public void onUtteranceCompleted(String utterance)
{
MundAnimation.stop();
//startVoiceRecognitionActivity();
System.out.println("drin");
}
(...)