开发者

android determine programmatically if voice dictation on soft keyboard is enabled

I am writing an app that requir开发者_开发百科es 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜