catch IllformedLocaleException

This commit is contained in:
sonora 2016-12-20 14:31:36 +01:00
parent 79b5bbfbeb
commit 9ecf9c9b02

View file

@ -168,8 +168,12 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
//#3344: Try Locale builder instead of constructor (only available from API 21)
if (android.os.Build.VERSION.SDK_INT >= 21) {
final String[] languageFields = language.split("\\_");
final Locale newLocale = new Locale.Builder().setLanguage(languageFields[0]).setScript("").setRegion(languageFields[1]).build();
try {
final String[] languageFields = language.split("\\_");
final Locale newLocale = new Locale.Builder().setLanguage(languageFields[0]).setScript("").setRegion(languageFields[1]).build();
} catch (IllformedLocaleException e) {
final Locale newLocale = new Locale(language);
}
} else {
final Locale newLocale = new Locale(language);
}