使用adb隐藏软键盘

7
我想使用adb shell命令隐藏软键盘。是否有特定的命令可以这样做,或者通过任何方式可以获取当前聚焦窗口对象在adb上,如果显示可以隐藏键盘?
5个回答

11

2

比这里其他的答案要合理得多 - forresthopkinsa

2
@Matthias Miro的回答已经过时,而且在Android 9上对我无效。 相反,我在GitHub问题讨论帖中找到了下面的解决方案,它起作用:
  1. 安装Null Keyboard
  2. 通过ADB选择它:adb shell ime set com.wparam.nullkeyboard/.NullKeyboard

要获得原始键盘:

  1. 列出所有可用的键盘:adb shell ime list -s -a
  2. 通过以下方式选择其中一个:adb shell ime set [来自前一个命令的键盘行]

1

我发现通过adb可以找到更快更简单的解决方案,即完全禁用键盘。

您可以使用以下命令永久隐藏键盘:

adb shell pm disable-user com.android.inputmethod.latin

0
否则只禁用一次(相当于在Appium测试自动化中隐藏键盘)
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"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接