Example usage for android.speech RecognizerIntent EXTRA_SUPPORTED_LANGUAGES

List of usage examples for android.speech RecognizerIntent EXTRA_SUPPORTED_LANGUAGES

Introduction

In this page you can find the example usage for android.speech RecognizerIntent EXTRA_SUPPORTED_LANGUAGES.

Prototype

String EXTRA_SUPPORTED_LANGUAGES

To view the source code for android.speech RecognizerIntent EXTRA_SUPPORTED_LANGUAGES.

Click Source Link

Document

The key to the extra in the Bundle returned by #ACTION_GET_LANGUAGE_DETAILS which is an ArrayList of String s that represents the languages supported by this implementation of voice recognition - a list of strings like "en-US", "cmn-Hans-CN", etc.

Usage

From source file:com.ct.speech.HintReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    if (getResultCode() != Activity.RESULT_OK) {
        return;/*from   w w w  .  j a  v  a  2 s.  co m*/
    }
    // the list of supported languages.
    ArrayList<CharSequence> hints = getResultExtras(true)
            .getCharSequenceArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);

    // Convert the map to json
    JSONArray languageArray = new JSONArray(hints);
    PluginResult result = new PluginResult(PluginResult.Status.OK, languageArray);
    result.setKeepCallback(false);
    // speechRecognizer.callbackId = "";
    speechRecognizerPlugin.success(result, "");
}

From source file:com.corumgaz.mobilsayac.VoiceRecognizer.LanguageDetailsChecker.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle results = getResultExtras(true);

    // get the list of supported languages
    if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) {
        // Convert the map to json
        supportedLanguages = results.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
        JSONArray jsonLanguages = new JSONArray(supportedLanguages);
        callbackContext.success(jsonLanguages);
    } else {/*from w  w w . j av  a  2  s.c o  m*/
        callbackContext.error("Could not retrieve the list of supported languages");
    }
}