0

我正在尝试实现在 TextToSpeech 功能完成后将用户带回主屏幕的意图,但它不起作用,我不知道为什么。这是我的代码:

public void playText(){     
    String text = typeNewMessageEditText.getText().toString();
    HashMap<String, String> myHashRender = new HashMap<String, String>();
    myHashRender.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "completed");
    tts.speak(text, TextToSpeech.QUEUE_FLUSH, myHashRender);        
}


@Override
public void onUtteranceCompleted(String utteranceId) {
    if (utteranceId.equals("completed")){   
                Intent displayMainActivity = new Intent (this, MainActivity.class);
                startActivity(displayMainActivity);
    }   
}
4

0 回答 0