如何以编程方式禁用/启用Android的物理键盘?键盘、物理、方式、Android

2023-09-08 09:02:26 作者:煮酒送别

我有我开发使用连接到摩托罗拉Xoom某些输入一个USB HID设备的应用程序。然而,大多数的时候我仍然想使用屏幕键盘。

I have an application that I'm developing that uses a USB HID device connected to a Motorola Xoom for some input. However, the majority of the time I still want to use the on-screen keyboard.

有没有一种方法来禁用/启用Android 3.0以上版本使用硬件键盘?我想表现得像它会应用,也有没有连接的键盘。

Is there a way to disable/enable the use of hardware keyboard in Android 3.0+? I'd like the application to behave like it would, had there not been a keyboard connected.

推荐答案

以及你能想到的一个解决方案是...

well one solution you can think of is ..

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    return true;
}
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    return true;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    return true;
}

这将避免键盘键preSS过程中的任何行动。但没有办法,你可以禁用Android键盘,因为它会使用一些本地方法。

this will avoid any actions during keyboard key press. but there is no way you can disable android keyboard since it will use some native methods.