Android的编程方式确定是否启用了软键盘的语音听写 [英] android determine programmatically if voice dictation on soft keyboard is enabled

查看:193
本文介绍了Android的编程方式确定是否启用了软键盘的语音听写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写信,要求高安全级别的应用程序。该应用程序将被部署在Droid X的设备上。我不能让用户访问语音到软键盘的文本特征(通过触摸麦克风图示),因为音频和文本不能通过互联网发送。有一种方法通过将语言和放大器来禁止设置此功能;键盘 - >多点触摸键盘 - >然后取消选择语音听写复选框。当此复选框被选中,软键盘上的麦克风图标将被禁用。我需要的是能在我的应用程序来验证这个功能依然处于关闭状态,当用户在我的应用程序的任何活动,其中有激活软键盘一个TextView。我曾尝试以下code,但它显然是不检查我关掉了的功能,因为它仍然表明,语音识别被打开,即使语音听写已被禁用。有没有什么办法编程如果启用了软键盘的语音听写功能来专门检查?

 软件包管理系统PM = getPackageManager();< BR>
清单活动= pm.queryIntentActivities(新意图(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
如果(activities.size()!= 0){
语音识别被打开....顽皮的使用者!
displayAlertMessage(你是淘气您打开语音识别...没有数据录入将被允许直到这个功能是关闭的!);
}


解决方案

因此​​,有2边到这一点。首先,它看起来并不像有一个可靠的/干净的方式以编程方式确定它是否被禁用。在一般的方式的声音输入被设置应该从输入的输入区分:在结构上不应该能够告诉一个或另一个之间的差异。您code以上检查,看是否活动丢失:禁用它不会删除活动

在另一方面:看 InputMethodManager 小号<一个href=\"http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html#getCurrentInputMethodSubtype%28%29\"相对=nofollow> getCurrentInputMethodSubtype :这似乎是能够的表示输入模式。这可能会做你想做的,但不能肯定。

让我知道。

I am writing an app that requires a high level of security. The app will be deployed on a Droid X device. I cannot allow the user to access the voice to text feature of the soft keyboard (by touching the microphone icon) because the audio and text cannot be sent over the internet. There is a way to disable this feature in Settings by going to Language & keyboard --> Multi-touch keyboard --> and then uncheck the Voice dictation checkbox. When this checkbox is unchecked, the microphone icon on the soft keyboard is disabled. What I need is to be able to verify in my app that this feature is still turned off when the user is in any activity in my app where there is a TextView that activates the soft keyboard. I have tried the following code, but it apparently isn't checking the feature I turned off because it still indicates that voice recognition is turned on even when Voice dictation has been disabled. Is there any way programmatically to specifically check if the Voice dictation feature of the soft keyboard is enabled?

PackageManager pm = getPackageManager();<br>
List activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (activities.size() != 0) {
voice recognition is turned on....NAUGHTY USER!
displayAlertMessage("You are naughty! You turned on voice recognition...No data entry will be allowed until this feature is turned off!");
}

解决方案

So there's 2 sides to this. First, it doesn't look like there is a reliable/clean way to determine programmatically if it is disabled. In general the way the voice input is set up it should be indistinguishable from typed input: structurally you shouldn't be able to tell the difference between one or the other. Your code above checks to see if the Activity is missing: disabling it does not remove the Activity.

On the other hand: look at the InputMethodManager's getCurrentInputMethodSubtype: this appears to be able to indicate the input mode. That might do what you want, but not sure.

Let me know.

这篇关于Android的编程方式确定是否启用了软键盘的语音听写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆