onUtteranceCompleted方法中的意图不起作用

时间:2013-04-20 00:08:48

标签: android android-intent onutterancecompleted

我正在尝试实现一个意图,一旦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);
    }   
}

0 个答案:

没有答案