Fix for setting app not playing tts sample.

Bug: 7666482
Change-Id: I36a775312d62d3d7a5ee600b540a328b377b46c9
This commit is contained in:
Przemyslaw Szczepaniak
2012-12-14 14:50:45 +00:00
committed by Android (Google) Code Review
parent 0cfbb7aabb
commit a7d2c93c2b

View File

@@ -214,7 +214,13 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
if (TextUtils.isEmpty(currentEngine)) currentEngine = mTts.getDefaultEngine();
Locale currentLocale = mTts.getLanguage();
Locale defaultLocale = mTts.getDefaultLanguage();
if (defaultLocale == null) {
Log.e(TAG, "Failed to get default language from engine " + currentEngine);
return;
}
mTts.setLanguage(defaultLocale);
// TODO: This is currently a hidden private API. The intent extras
// and the intent action should be made public if we intend to make this
@@ -222,11 +228,9 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
// doesn't work.
Intent intent = new Intent(TextToSpeech.Engine.ACTION_GET_SAMPLE_TEXT);
if (currentLocale != null) {
intent.putExtra("language", currentLocale.getLanguage());
intent.putExtra("country", currentLocale.getCountry());
intent.putExtra("variant", currentLocale.getVariant());
}
intent.putExtra("language", defaultLocale.getLanguage());
intent.putExtra("country", defaultLocale.getCountry());
intent.putExtra("variant", defaultLocale.getVariant());
intent.setPackage(currentEngine);
try {