androidandroid-softkeyboardandroid-speech-api

Which event is triggered when speech-to-text is activated on android soft-keyboard?


I want to trigger an additional event in an android app when the default speech recognition button is touched on the android soft-keyboard. Is there any method catching this event, or what is the code for the speech recognition button to modify the keyboard.xml directly? Any solution would be appreciated, thanks.


Solution

  • None. Software keyboards don't generate keyboard events. They send text via InputConnection.commiteTexzt. For a button that causes no text like speech, it would internally launch a speech recognition app, either the default one or one of their choosing.

    If you're looking to implement a basic keyboard yourself, just have the key launch an intent with action RecognizerIntent.ACTION_RECOGNIZE_SPEECH. If you want something fancier you pretty much have to bind with a specific voice recognition library directly.