我有一个朗读菜单选项,它与API 15一起运行良好。但是无法在API中工作.19。代码中没有错误,但点击菜单不会导致任何问题。这是代码: 我在onCreate
中添加了这个 mSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS)
result=mSpeech.setLanguage(Locale.US);
if(result==TextToSpeech.LANG_MISSING_DATA ||
result==TextToSpeech.LANG_NOT_SUPPORTED){
Log.e("error", "This Language is not supported");
}
}
});
这是我点击菜单时运行的代码:
case R.id.read_aloud_menu_item:
System.out.println("goes into read aloud case");
System.out.println(TextToSpeech.ERROR);
mSpeech.speak("Hello, this is a sample data", TextToSpeech.QUEUE_FLUSH, null);