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

Apps Help with scripts for my text-to-speech app

mehboob

Lurker
Sep 12, 2011
4
0
Am new to android world and working on text-to-speech app, I got struck in between this app, The problem is my activity-2 image is appearing on screen before my activity-1 has completed reading its content.When i use the following code activity-2 is not starting at all.Any help would be appreciated :).Thanks


if (status == TextToSpeech.SUCCESS) {

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_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 t) {

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

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones