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.
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
tts = new TextToSpeech(this, this);
tts.setOnUtteranceCompletedListener(this);
}
else {
// missing data, install it
Intent Intent = new Intent();
Intent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(Intent);
}
}
}
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);
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en