• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem with text to speech application

mehboob

Lurker
Hi, Am working on Text-to-speech app, In which i have 3 activities, I want my activity-2 to be displayed after my activity-1 has completed its text.I also tried out with onUtteranceCompleted(String), Using this it is not installing my activity-2. This is a part of code what i had written 4 that.Any help would be appreciated.

public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
Toast.LENGTH_LONG).show();
String text= tt.getText().toString();
if (text!=null && text.length()>0) {
Toast.makeText(activity1.this, "Speaking: " + text, Toast.LENGTH_LONG).show();


HashMap<String, String> myHash = new HashMap();
myHash.put(TextToSpeech.Engine.KEY_PARAM_STREAM,
String.valueOf(AudioManager.STREAM_NOTIFICATION));
myHash.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,
"completed");
tts.speak(text, TextToSpeech.QUEUE_ADD, myHash);
tts.setOnUtteranceCompletedListener(this);

}
else if (status == TextToSpeech.ERROR) {
Toast.makeText(activity1.this,
"Error occurred while initializing Text-To-Speech engine", Toast.LENGTH_LONG).show();
}

}

}
public void onUtteranceCompleted(String text1) {

if(text1 == "completed"){
Intent i = new Intent(this, Activity2.class);
startActivity(i);
}
}


}
 
Back
Top Bottom