本文整理汇总了Java中android.speech.tts.TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE属性的典型用法代码示例。如果您正苦于以下问题:Java TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE属性的具体用法?Java TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE怎么用?Java TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.speech.tts.TextToSpeech
的用法示例。
在下文中一共展示了TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInit
@Override
public void onInit(int status) {
if (mTts == null) {
EasyTrackerUtils.sendNonFatalException(this,
new IllegalStateException("TTS field somehow null in TTS onInit callback"));
return;
}
// text to speech engine ready
mTtsReady = true;
Locale currentLocale = Locale.getDefault();
final String lang = currentLocale.getLanguage();
// Do we currently have enough translated strings for the language?
// TODO fix this shit... oh god.
boolean haveTranslations = (
lang.matches("en") ||
lang.matches("fr") ||
lang.matches("ru") ||
lang.matches("pt") ||
lang.matches("ko"));
if (haveTranslations) {
int langAvailable = mTts.isLanguageAvailable(currentLocale);
if (langAvailable == TextToSpeech.LANG_AVAILABLE ||
langAvailable == TextToSpeech.LANG_COUNTRY_AVAILABLE ||
langAvailable == TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE) {
mTts.setLanguage(currentLocale);
return;
}
}
// TODO inform the user that TTS data isn't available for their language, and what
// they can do to get it etc.
mTts.setLanguage(Locale.US);
}