HXSP1947 HXSP1947 - 1 year ago 133
Android Question

Disable speech to text button (Micro phone) on soft input keyboard in android programmatically

Thanks in advance for the help.

I am developing an android application for research purposes and need to disable the speech to text button on the soft input keyboard. The reason for this is due to concurrency issues that arise since the application I am developing uses the microphone. I understand that for a general application disabling keys is generally seen as impossible (since users may change default keyboards). I know for a fact that the default keyboard will be used.

With this in mind is it possible to disable certain keys? I believe that at the least I should be able to specify the input type such that the microphone button is hidden. I say this because if I disable speech to text in the settings (not programmatically, but manually as a user) the microphone icon is removed from the keyboard. I'm open to any possible solution (with the exception of not using the default keyboard) as this application will not appear on the play store.

Answer Source

You can't force the user input through anything other than pre-defined keyboards that already exist in the user's device.

The only way you could get around this is by programming your own custom, on-the-fly keyboard, and that is a very bad idea.

Just disable voice input programmatically by using XML declarations in the EditText you're looking at. You can do this with the attribute:

android:privateImeOptions="nm"   // nm stands for No Microphone.

If you want to set it programmatically you can try this::

        // deprecated i guess
         // this one is new but it works only with Google Keyboard.

You can combine values in PrivateImeOptions parameter in CVS form so best option is to use:


Take a look through here and see if you can find what you're looking for.

More info about Google Keyboard here -> look for method setOptions

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download