Search code examples
androidandroid-activityinputvoice

RESULT_CANCELED from RecognizerIntent every time before voice activity finishes


I'm running the following code in my onCreate of an Activity:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
       RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Some String");
startActivityForResult(intent, VOICE_INPUT_CODE);

Before the voice activity even finishes though, I always receive a RESULT_CANCELED in the resultCode and the voice data is missing.

Thanks!


Solution

  • The problem was that I had

    launchMode="singleInstance" set on that activity.