为什么TextToSpeech.getLanguage()*有时*会返回null?

Ete*_*ner 5 android text-to-speech

在我的应用程序中,我在实例化TextToSpeech(根据LogCat约800ms )之后很好地调用TextToSpeech.getLanguage(),但它有时(并非总是)返回null,尽管在系统的TextToSpeech设置中正确设置了语言:

System Settings > Language & input > 
  Text-to-speech output > Google Text-to-speech > English (United Kingdom)
Run Code Online (Sandbox Code Playgroud)

这只发生在Jelly Bean(Android 4.1.1)中.在Android 2.2中不会发生这种情况.

这是一个已知的Android错误吗?或者我做错了什么?

我在我的应用程序的主要活动中实例化BTW,TextToSpeech:

new TextToSpeech(this, this); 
Run Code Online (Sandbox Code Playgroud)

实例化和对TextToSpeech.getLanguage()的调用 都在同一个线程中进行(因此保证了调用顺序).

Hoa*_*yen 2

你必须在onInit()中调用getLanguage(),有时onInit()的调用需要几秒钟的时间。