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

由网友(嘴上没毛办事不牢@)分享简介:在我的应用程序,我称之为TextToSpeech.getLanguage()以及实例化文字转语音(根据LogCat中〜800毫秒),但之后的有时(不总是)返回null,尽管在系统的文字转语音设置正确设置语言:In my app, I call TextToSpeech.getLanguage() well after...

在我的应用程序,我称之为TextToSpeech.getLanguage()以及实例化文字转语音(根据LogCat中〜800毫秒),但之后的有时(不总是)返回null,尽管在系统的文字转语音设置正确设置语言:

In my app, I call TextToSpeech.getLanguage() well after instantiating TextToSpeech (~800ms according to LogCat), yet it sometimes (not always) return null, despite the language set properly in the system's TextToSpeech settings:

System Settings > Language & input > 
  Text-to-speech output > Google Text-to-speech > English (United Kingdom)

这只是发生在果冻豆(Android的 4.1.1 )。它不会在Android 2.2的发生。

This only happens in Jelly Bean (Android 4.1.1). It doesn't happen in Android 2.2.

这是一个已知的Andr​​oid错误?还是我做错了什么?

Is this a known Android bug? Or am I doing something wrong?

我实例,顺便说一句,文字转语音在我的应用程序与主要活动:

I instantiate, BTW, TextToSpeech in my app's main activity with:

new TextToSpeech(this, this); 

和两个实例,并调用TextToSpeech.getLanguage()在同一个线程(因此呼叫顺序保证的)制成。

And both instantiation and the call to TextToSpeech.getLanguage() are made in the same thread (thus order of calls is guaranteed).

推荐答案

您必须调用使用getLanguage()中的OnInit(),有时需要对OnInit的几秒钟()被调用。

You have to call getLanguage () in onInit (), sometimes it takes a few second for onInit () to be called.

阅读全文

相关推荐

最新文章