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

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

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

  1. mehboob

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

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

    Advertisement

Share This Page

Loading...