private synchronized void doRecognize(
      final Recognizer.Listener callback,
      int endOfSpeechRecognitionMode,
      boolean isNoStartPrompt,
      boolean isNoStopPrompt) {

    // "singleton" recognition: only one recognition process at a time is allowed
    //							--> ensure all previous processes are stopped.
    if (_currentRecognitionHandler != null && _currentRecognizer != null) {
      _currentRecognizer.cancel();
    }
    _currentRecognitionHandler = callback;

    _currentRecognizer =
        _speechKit.createRecognizer(
            Recognizer.RecognizerType.Dictation,
            endOfSpeechRecognitionMode,
            _currentLanguage,
            _recognitionListener,
            _handler);

    if (isNoStartPrompt) {
      _currentRecognizer.setPrompt(Recognizer.PromptType.RECORDING_START, null);
    }

    if (isNoStopPrompt) {
      _currentRecognizer.setPrompt(Recognizer.PromptType.RECORDING_STOP, null);
    }

    _currentRecognizer.start();
  }
 public void cancelRecognition() {
   if (_currentRecognizer != null) _currentRecognizer.cancel();
 }