Q:

Android Speech Recognition App

I want to make an app that will take a the command from the user and show it in the Edittext (or any other container). I'm using google speech recognition but it shows me a bunch of sentences that the Engine Heard.. I want to get the right one from all those option without showing the list into the Edittext.. 
And if possible I'll like to do that in continuous sentence (like, Hi Friend. please come for the meeting, you are late). Please help me out with this.
Thanks in Advance :) 

A:

This code can be wired up to a "Speak" button and will receive a single string, which is the best match to whatever was said.
To start the speech recognition activity:
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1;

private void startVoiceRecognitionActivity() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT,"Speak Now");
    startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

To receive the result:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches != null && matches.size() > 0) {
            String spokenText = matches.get(0);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

