1. Download our Official Android App: Forums for Android!

Apps Problem with text to speech application

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

  1. mehboob

    mehboob Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Sep 12, 2011

    Sep 12, 2011
    4
    0
    5
    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);
    }
    }


    }
     

    Advertisement

Share This Page

Loading...