在我的应用程序的主要活动中,我发出一个 Intent ACTION_CHECK_TTS_DATA
:
Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(intent, 0);
当它返回时,在 onActivityResult() 中,我尝试列出可用的声音:
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
String availableVoices = intent.getStringExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
Log.d("TTS engine installed", "Available voices: " + availableVoices);
new TextToSpeech(this, this);
}
}
}
我正在接收CHECK_VOICE_DATA_PASS
,一切正常,但根据 Log.d() 消息,intent.getStringExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES)
返回 null!
我知道我的手机里面有不少声音,安装好,工作正常,为什么getStringExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES)
返回null呢?
我错过了什么?