]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Catch exceptions when setting TTS language.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index 78c18231c935c7162a1a5461c5c1a482c6b10b72..67c1d834003bef2a626e24e840d45069f822f149 100644 (file)
@@ -668,11 +668,15 @@ public class DictionaryActivity extends ActionBarActivity {
         }
         final Locale locale = new Locale(dictionary.indices.get(i).sortLanguage.getIsoCode());
         Log.d(LOG, "Setting TTS locale to: " + locale);
+        try {
         final int ttsResult = textToSpeech.setLanguage(locale);
         if (ttsResult != TextToSpeech.LANG_AVAILABLE &&
                 ttsResult != TextToSpeech.LANG_COUNTRY_AVAILABLE) {
             Log.e(LOG, "TTS not available in this language: ttsResult=" + ttsResult);
         }
+        } catch (Exception e) {
+            Toast.makeText(this, getString(R.string.TTSbroken), Toast.LENGTH_LONG).show();
+        }
     }
 
     void onLanguageButtonClick() {