Example usage for android.speech.tts TextToSpeech isLanguageAvailable

List of usage examples for android.speech.tts TextToSpeech isLanguageAvailable

Introduction

In this page you can find the example usage for android.speech.tts TextToSpeech isLanguageAvailable.

Prototype

public int isLanguageAvailable(final Locale loc) 

Source Link

Document

Checks if the specified language as represented by the Locale is available and supported.

Usage

From source file:Main.java

/**
 * get a descriptions of all the languages available as determined by
 * {@link TextToSpeech#isLanguageAvailable(Locale)}
 *///from   w w  w  .j a va  2  s  .  c o m
public static String getLanguageAvailableDescription(TextToSpeech tts) {
    StringBuilder sb = new StringBuilder();
    for (Locale loc : Locale.getAvailableLocales()) {
        int availableCheck = tts.isLanguageAvailable(loc);
        sb.append(loc.toString()).append(" ");
        switch (availableCheck) {
        case TextToSpeech.LANG_AVAILABLE:
            break;
        case TextToSpeech.LANG_COUNTRY_AVAILABLE:
            sb.append("COUNTRY_AVAILABLE");
            break;
        case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
            sb.append("COUNTRY_VAR_AVAILABLE");
            break;
        case TextToSpeech.LANG_MISSING_DATA:
            sb.append("MISSING_DATA");
            break;
        case TextToSpeech.LANG_NOT_SUPPORTED:
            sb.append("NOT_SUPPORTED");
            break;
        }
        sb.append(NEW_LINE);
    }
    return sb.toString();
}