How to connect SpeechRecognizer to RecognizerInten

2019-05-17 19:19发布

问题:

I am trying to wrap my mind around the SpeechRecognizer. I have a SpeechRecognizer with my own Recognition Listener:

rec = SpeechRecognizer.createSpeechRecognizer(this);
    rec.setRecognitionListener(new RecognitionListener() {
        //Lots of overrides that work perfectly fine
    });

Wich works fine when I launch it by using rec.startListening(intent); But my intent happens to have some Extras:

        intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
    intent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, true);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "de-DE");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);

    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

All of those, the Recognizer rec totally ignores when launching with rec.startListening(intent);

On the other hand, when I use startActivityForResult(intent, 1000, intent.getExtras()); to start the recognition, the Code from the RecognitionLister is totally ignored.

How do I start the recognition with my own RecognitionListener AND the intent-extras?

Layna

=============

PS: I have by now realised that startActivityForResult has absolutely no reason to use the code for the ReconitionListener.... but I am still confused why startListening should ignore extras.