Code example for SpeechRecognizer

Methods: setRecognitionListener, startListening

-1
                // TODO(satish): Show an error UI here. 
                Log.e("ChromeView", "Could not get speech recognizer.");
                nativeDidCompleteRecognition(sessionId);
                return; 
            } 
            mRecognizer.setRecognitionListener(this);
        } 
 
        mSessionId = sessionId;
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, grammar);
        intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
                        "org.chromium.content.browser"); 
        // TODO(satish): Change this hardcoded value to a parameter once 
        // maxresults is implemented as an attribute in webkit. 
        intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
        mRecognizer.startListening(intent);
 
        // TODO(satish): Add a UI to indicate that recognition is in progress 
        // and to show mic volume levels. 
    }