我想使用adb shell命令隐藏软键盘。是否有特定的命令可以这样做,或者通过任何方式可以获取当前聚焦窗口对象在adb上,如果显示可以隐藏键盘?
您可以使用以下方式隐藏键盘:
adb shell input keyevent 111
您可以在这里找到所有的关键事件: http://developer.android.com/reference/android/view/KeyEvent.html
adb shell input keyevent 4 # KEYCODE_BACK
adb shell ime set com.wparam.nullkeyboard/.NullKeyboard
要获得原始键盘:
adb shell ime list -s -a
adb shell ime set [来自前一个命令的键盘行]
我发现通过adb可以找到更快更简单的解决方案,即完全禁用键盘。
您可以使用以下命令永久隐藏键盘:
adb shell pm disable-user com.android.inputmethod.latin
adb shell ime reset
$ adb shell ime -h
ime <command>:
list [-a] [-s]
prints all enabled input methods.
-a: see all input methods
-s: only a single summary line of each
enable [--user <USER_ID>] <ID>
allows the given input method ID to be used.
--user <USER_ID>: Specify which user to enable. Assumes the current user if not specified.
disable [--user <USER_ID>] <ID>
disallows the given input method ID to be used.
--user <USER_ID>: Specify which user to disable. Assumes the current user if not specified.
set [--user <USER_ID>] <ID>
switches to the given input method ID.
--user <USER_ID>: Specify which user to enable. Assumes the current user if not specified.
reset [--user <USER_ID>]
reset currently selected/enabled IMEs to the default ones as if the device is initially booted w
ith the current locale.
--user <USER_ID>: Specify which user to reset. Assumes the current user if not specified.
adb shell "ime list -s"
adb shell "ime disable {IME_KEYBOARD_VALUE}"
adb shell "ime reset"