public static void setLanguage(boolean changeLanguage, String language) { if (!changeLanguage) language = java.util.Locale.getDefault().getLanguage(); if (language.equals("English") || language.equals("en_US") || language.equals("en_GB") || language.equals("en_CA") || language.equals("en_AU") || language.equals("en_NZ") || language.equals("en_SG") ) myLanguage = new TTSNotifierLanguageEN(); else if (language.equals("Nederlands") || language.equals("nl_NL") || language.equals("nl_BE")) myLanguage = new TTSNotifierLanguageNL(); else if (language.equals("Français") || language.equals("fr_FR") || language.equals("fr_BE") || language.equals("fr_CA") || language.equals("fr_CH")) myLanguage = new TTSNotifierLanguageFR(); else if (language.equals("Deutsch") || language.equals("de_DE") || language.equals("de_AT") || language.equals("de_CH") || language.equals("de_LI")) myLanguage = new TTSNotifierLanguageDE(); else myLanguage = new TTSNotifierLanguageEN(); setLanguageTts(myLanguage.getLocale()); }
@Override public void onStart(Intent intent, int startId) { Log.v("TTSNotifierService", "onStart()"); if (myTts == null) { try { myTts = new TextToSpeech(context, ttsInitListener); } catch (java.lang.ExceptionInInitializerError e) { e.printStackTrace(); } } if (mPrefs.getBoolean("cbxChangeLanguage", false)) setLanguageTts(myLanguage.getLocale()); Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = intent; mServiceHandler.sendMessage(msg); }