/** Handle the results from the recognition activity. */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("Speech", "GOT SPEECH RESULT " + resultCode + " req: " + requestCode); if (recognizer.isSpeechCode(requestCode)) { recognizer.handleRecognition(requestCode, resultCode, data, RESULT_OK); boolean heardSomething = recognizer.getLastThingsHeard().size() > 0; if (heardSomething) { // after capture it report what was heard Log.d("Speech", "I heard: " + recognizer.getLastThingsHeard()); } receiveWhatWasHeard(recognizer.getLastThingsHeard()); // Log.d(D_LOG, "UNLOCK: unlocking collect lock for speech"); // executeState.getCollectLock().unlock(); } else { Log.d(D_LOG, "speech activity: unrecogonized result"); } super.onActivityResult(requestCode, resultCode, data); }
public void gatherSpeech() { Intent recognizeIntent = recognizer.getRecognizeIntent(); recognizer.clearLastThingHeard(); startActivityForResult(recognizeIntent, SpeechGatherer.VOICE_RECOGNITION_REQUEST_CODE); }