I need to start a drawable animation when my text to speech is starting and stop this one when the text to speech is over, but i can't stop the animation.
Code:
tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "This Language is not supported");
}
} else {
Log.e("TTS", "Initilization Failed!");
}
}
});
private void speak(String text){
animation.start();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, null);
}else{
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
and here my animationdrawable xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selected" android:oneshot="false" >
<item android:drawable="@drawable/face_1a_mini" android:duration="250" />
<item android:drawable="@drawable/face_1b_mini" android:duration="250" />
<item android:drawable="@drawable/face_1c_mini" android:duration="250" />
<item android:drawable="@drawable/face_1d_mini" android:duration="250" />
</animation-list>