Use API 21.

This commit is contained in:
Reece H. Dunn
2014-10-28 18:30:16 +00:00
parent 6ac54860a1
commit 3d2308e285
5 changed files with 67 additions and 31 deletions
@@ -16,6 +16,7 @@
package com.reecedunn.espeak.test;
import android.os.Build;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.test.AndroidTestCase;
@@ -93,4 +94,19 @@ public class TextToSpeechTestCase extends AndroidTestCase
{
return mEngine;
}
@SuppressWarnings("deprecation")
public static Locale getLanguage(TextToSpeech engine) {
if (engine != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
android.speech.tts.Voice voice = engine.getVoice();
if (voice != null) {
return voice.getLocale();
}
} else {
return engine.getLanguage();
}
}
return null;
}
}