Search code examples
androidkeyboardtranslationvoice

Android: Unable to launch "Google Voice Typing" programmatically


So, I have this simple application for speech to text translation.

I am using this to launch the google speech to text translator in my activity:

val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Hi speak something")
startActivityForResult(intent, 1)

It launches the following screen - Now this allows me to speak only one sentence at a time but not a continuous speech to text translation enter image description here

Instead of this, I want to launch the "google voice typing" keyboard programmatically whenever I want as it allows the continuous speech to text translation. enter image description here

I couldn't find any sources to launch "google voice typing" keyboard.

"SwiftKey" keyboard is having a mic button, pressing on it actually launching the "google voice typing" keyboard.

So I am thinking there should be a way to launch "google voice typing" keyboard programmatically.


Solution

  • As far as I know you cannot programmatically pick a specific Input Method Editor (IME) (e.g. Google Voice Typing) to be used in your application, and you cannot even tag your input fields to demand voice input (see Start Android keyboard in voice recognition mode).

    SwiftKey itself is an IME, thus it can call something like setInputMethodAndSubtype to change to a different IME.