在我的应用程序中,我在实例化 TextToSpeech(根据 LogCat 约为 800 毫秒)之后很好地调用了TextToSpeech.getLanguage( ),但有时(并非总是)返回 null,尽管在系统的 TextToSpeech 设置中正确设置了语言:
System Settings > Language & input >
Text-to-speech output > Google Text-to-speech > English (United Kingdom)
这只发生在 Jelly Bean (Android 4.1.1 ) 中。它不会发生在 Android 2.2 中。
这是一个已知的 Android 错误吗?还是我做错了什么?
我在我的应用程序的主要活动中实例化,顺便说一句,TextToSpeech:
new TextToSpeech(this, this);
并且实例化和对 TextToSpeech.getLanguage()的调用都是在同一个线程中进行的(因此保证了调用的顺序)。