How do I programmatically disable/enable the physical keyboard in Android?

社会主义新天地 提交于 2020-01-03 05:12:13

问题


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.

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.


回答1:


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;
}

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.



来源:https://stackoverflow.com/questions/7118810/how-do-i-programmatically-disable-enable-the-physical-keyboard-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!