如何检查是否使用本机/硬件键盘? [英] How to check if the native/hardware keyboard is used?

查看:83
本文介绍了如何检查是否使用本机/硬件键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查是否使用了本机/硬件键盘,如果可能的话,我想禁用第三方键盘.

I want to check if the native/hardware keyboard is used, and also if possible I want to disable the third party keyboards.

我的目标很简单,我只使用本地android软键盘在编辑框中输入值,而其他键盘都不能做到这一点

My goal is simple I use just the native android soft keyboard for entering values in my edit boxes and no other keyboard should be able to this

谢谢

编辑

我知道做我想做的事情不是一个好主意,我知道android的基本思想是拥有意图,活动和服务,他们知道根据意图过滤器处理某些类型的意图.但这在每条规则中都有一个例外,尤其是当我们谈论安全性时.

I know it is not good idea to do what I am trying to do, I know that the basic idea of android is to have intents and activities and services who know to handle some types of intent according intent-filter. But this in every rule there is an exception, especially when we talk about security.

我想禁用所有第三方键盘,如果无法通过某些API或其他方式来做到这一点...是否有解决此问题的方法?

I want to disable all third party keyboards, and if this is not possible to do it with some API or something... is there any workaround to this problem ?

编辑

String s=Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);

这将返回当前启用的输入法(键盘),但是我需要像系统键盘"之类的东西,并且看不到任何类似的标志:-(.

This returns the currently enabled input method (keyboard),but I need something like the 'system keyboard' and I do not see any flag like that :-(.

List<InputMethodInfo> list = m.getInputMethodList();

一种可能的解决方案是将list [0]用作我正在搜索的键盘,但是我不想继续执行该命令(除非该命令是保证始终使用索引为0的键盘来提供)用手机安装)

One possible solution is to take the list[0] as the keyboard I am searching, but I do not want to relay on the order (except if the order is garanteed that always the keyboard with index 0 is the one that comes install with the phone)

这是列表的值

[InputMethodInfo{com.htc.android.htcime/.HTCIMEService, settings: com.htc.android.htcime.HTCIMESettings}, InputMethodInfo{com.volosyukivan/.WiFiInputMethod, settings: null}]

推荐答案

我想检查是否使用了本机/硬件键盘

I want to check if the native/hardware keyboard is used

您可以使用Configuration对象查看设备的硬件键盘是否被隐藏.通常,这将暗示他们正在使用该键盘,因为在可用硬件键盘时,大多数设备不会显示IME.但是,某些设备可能同时支持这两种设备,而且我不知道外部键盘(USB,蓝牙)如何与此值交互.

You can use the Configuration object to see if the device's hardware keyboard is hidden. Usually, that would imply they are using that keyboard, since most devices do not show an IME when the hardware keyboard is available. However, some devices might support both simultaneously, and I don't know how external keyboards (USB, Bluetooth) interact with this value.

如果可能的话,我也想禁用第三方键盘.

also if possible I want to disable the third party keyboards.

幸运的是,这是不可能的.

Fortunately, this is not possible.

有没有解决此问题的方法?

is there any workaround to this problem ?

在这一点上,这一点没有问题.

There is no problem cited to this point in the question.

是的,不会高兴,但是如果您破坏他们的安全数据,他们会更加不高兴

yes the will not be happy, but they will be much more unhappy if you let their secure data to be corrupt

如果用户选择使用备用键盘,那就是他们作为用户的选择.用户完全可以根据需要切换键盘.用户完全有能力做出这些决定.由于内置了间谍软件的设备(例如

If users choose to use an alternative keyboard, that is their choice as users. The user is perfectly capable of switching keyboards if they wish. The user is perfectly capable of making these decisions. It is entirely possible that an alternative keyboard is more secure than a built-in one, due to devices loaded with spyware from the factor, such as CarrierIQ. Hence, your assumption that you are improving security by attacking the user's choice of keyboard is fundamentally flawed.

当然,您根本不必支持使用任何键盘,从而迫使用户使用您自己设计的某种屏幕输入选项.这也不是完全安全的(例如,窃听攻击),并且对于出于特定原因(例如盲人用户,运动控制问题的用户)选择某些第三方键盘的人来说,可能会导致可用性问题.

Of course, you do not have to support using any keyboard at all, forcing users to use some sort of on-screen input option that you devise yourself. This is not completely secure either (e.g., tapjacking attacks), and it may cause usability problems for people who chose certain third-party keyboards for specific reasons (e.g., blind users, users with motor control issues).

我不知道有什么方法可以确定固件本身的IME,尤其是由于设备和固件而异.

I am not aware that there is a way to definitively determine what the firmware's own IME is, particularly since this varies by device and firmware.

这篇关于如何检查是否使用本机/硬件键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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