Example usage for android.speech RecognizerIntent EXTRA_RESULTS

List of usage examples for android.speech RecognizerIntent EXTRA_RESULTS

Introduction

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

Prototype

String EXTRA_RESULTS

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

Click Source Link

Document

An ArrayList<String> of the recognition results when performing #ACTION_RECOGNIZE_SPEECH .

Usage

From source file:com.androzic.vnspeech.MapFragment.java

/**
 * Receiving speech input/*  ww  w .ja va2 s .  co m*/
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQ_CODE_SPEECH_INPUT: {
        if (resultCode == Activity.RESULT_OK && null != data) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String text = result.get(0);
            doTalkCommand(text);
            //TODO AI algorithm here
            //You can do language analyze here
        }
        break;
    }

    }
}

From source file:com.rfo.basic.Run.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CONNECT_DEVICE_SECURE:
        // When DeviceListActivity returns with a device to connect
        if ((resultCode == Activity.RESULT_OK) && (mInterpreter != null)) {
            mInterpreter.connectDevice(data, bt_Secure);
        }/*from ww  w . j a  v  a2 s .com*/
        break;
    case REQUEST_CONNECT_DEVICE_INSECURE:
        // When DeviceListActivity returns with a device to connect
        if ((resultCode == Activity.RESULT_OK) && (mInterpreter != null)) {
            mInterpreter.connectDevice(data, false);
        }
        break;
    case REQUEST_ENABLE_BT:
        // When the request to enable Bluetooth returns
        if (resultCode == Activity.RESULT_OK) {
            // Bluetooth is now enabled, so set up a chat session
            bt_enabled = 1;
        } else {
            bt_enabled = -1;
        }
        break;
    case VOICE_RECOGNITION_REQUEST_CODE:
        if (resultCode == RESULT_OK) {
            sttResults = new ArrayList<String>();
            sttResults = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        }
        sttDone = true;
        break;
    }
}