检测虚拟键盘的类型-Android

问题描述:

我有一个android应用程序,它处理来自标准键盘的输入,与Swype键盘给出的输入不同。有没有什么方法可以通过编程找出当前使用的键盘?检测虚拟键盘的类型-Android

谢谢!

+0

可能重复:http://*.com/questions/3380234/android-determine-active-input-method-from-code –

+0

是的!我之前搜索过它,但无法找到这样的帖子。谢谢! :) –

最好的方法是使用InputDeviceId。

int[] devicesIds = InputDevice.getDeviceIds(); 
for (int deviceId : devicesIds) { 
    //Check the device you want 
    InputDevice device = InputDevice.getDevice(deviceId); 
    //device.getName must to have virtual 
    //That check the keyboard type 
    device.getKeyboardType(); //returns an int 
} 

参考:

https://developer.android.com/reference/android/view/InputDevice.html#getKeyboardType%28%29