1. Are you ready for the Galaxy S20? Here is everything we know so far!

Problem with text to speech application

Discussion in 'Android Development' started by mehboob, Sep 14, 2011.

  1. mehboob

    mehboob Lurker
    Thread Starter

    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);
    }
    }


    }
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...