在android中以编程方式禁用软输入键盘上的语音到文本按钮(微电话)(Disable speech to text button (Micro phone) on soft input keyboa

编程入门 行业动态 更新时间:2024-10-28 14:24:11
在android中以编程方式禁用软输入键盘上的语音到文本按钮(微电话)(Disable speech to text button (Micro phone) on soft input keyboard in android programmatically)

先谢谢您的帮助。

我正在开发一个用于研究目的的Android应用程序,需要禁用软输入键盘上的语音到文本按钮。 这是因为我正在开发的应用程序使用麦克风时出现并发问题。 据我所知,对于一般应用程序,通常认为禁用密钥是不可能的(因为用户可能会更改默认键盘)。 我知道将使用默认键盘。

考虑到这一点是否可以禁用某些键? 我相信至少我应该能够指定输入类型,以便隐藏麦克风按钮。 我这样说是因为如果我在设置中禁用语音到文本(不是以编程方式,而是手动作为用户),则会从键盘上删除麦克风图标。 我对任何可能的解决方案持开放态度(不使用默认键盘除外),因为此应用程序不会出现在Play商店中。

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.

最满意答案

您无法通过用户设备中已存在的预定义键盘以外的任何其他方式强制用户输入。

解决这个问题的唯一方法是编写自己的自定义,即时键盘,这是一个非常糟糕的主意。

只需使用您正在查看的EditText中的XML声明以编程方式禁用语音输入。 您可以使用以下属性执行此操作:

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

如果你想以编程方式设置它,你可以试试这个::

// deprecated i guess edt_txt.setPrivateImeOptions("nm"); // this one is new but it works only with Google Keyboard. edt_txt.setPrivateImeOptions("com.google.android.inputmethod.latin.noMicrophoneKey");

您可以在CVS表单中组合PrivateImeOptions参数中的值,因此最好的选择是使用:

edt_txt.setPrivateImeOptions("nm,com.google.android.inputmethod.latin.noMicrophoneKey");

看看这里 ,看看你是否能找到你想要的东西。

有关Google键盘的更多信息 - >查找方法setOptions

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 edt_txt.setPrivateImeOptions("nm"); // this one is new but it works only with Google Keyboard. edt_txt.setPrivateImeOptions("com.google.android.inputmethod.latin.noMicrophoneKey");

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

edt_txt.setPrivateImeOptions("nm,com.google.android.inputmethod.latin.noMicrophoneKey");

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

更多推荐

本文发布于:2023-07-20 07:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1195986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中以   语音   按钮   文本   键盘

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!