I want to use startActivityForResult to start a RecognizerIntent in Android, but without the dialog window, to basically keep the UI in the front from which the activity is launched (the background with 'Session' in the screenshot below).
When I use startActivityForResult(audioIntent,1)
to start my speech recognition in Android, a dialog of the RecognizerIntent shows up like the screenshot below:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
if (!intent.hasExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE))
{
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
"com.dummy");
}
startActivityForResult(intent,1);
I am aware that I could use the SpeechRecognizer
class which doesn't have a dialogue, but it doesn't have all the capabilities that I need. Is there any way to use RecognizerIntent startActivityForResult without a visible dialog? All the other similar questions on SO use SpeechRecognizer, which I want to avoid.