admin管理员组

文章数量:1632346

使用adb命令操作Android输入法

    • 1.获取当前设备有效的输入法列表
    • 2.获取当前设备有效输入法的详细信息
    • 3.常看当前`正在使用`的输入法
    • 4.切换输入法(设置默认输入法)
    • 5.附上帮助文档

最近碰到经常需要使用adb命令切换Android手机的输入法,在这里整理一个文章,作为备忘。

1.获取当前设备有效的输入法列表

命令:

adb shell ime list -s 

输出:

zekylldeMacBook-Pro:~ zekyll$ adb shell ime list -s
com.samsung.android.honeyboard/.service.HoneyBoardService
jp.jun_nama.test.utf7ime/.Utf7ImeService
com.github.uiautomator/.FastInputIME
com.sohu.inputmethod.sogou/.SogouIME
comease.nie.yosemite/.ime.ImeService
  • 注意:-s并不是已安装的所有输入法,而是安装并已勾选的输入法
    启用方式:
  • 系统设置>>通用>>语言和输入法>>勾选输入法
  • 使用命令的方式
zekylldeMacBook-Pro:~ zekyll$ adb shell ime enable jp.jun_nama.test.utf7ime/.Utf7ImeService
Input method jp.jun_nama.test.utf7ime/.Utf7ImeService: already enabled for user #0
zekylldeMacBook-Pro:~ zekyll$ 
  • 注意:若需要全部的输入法,需要使用-a命令
adb shell ime list -a 

2.获取当前设备有效输入法的详细信息

命令:

adb shell ime list  

输出:

zekylldeMacBook-Pro:~ zekyll$ adb shell ime list
com.samsung.android.honeyboard/.service.HoneyBoardService:
  mId=com.samsung.android.honeyboard/.service.HoneyBoardService mSettingsActivityName=com.samsung.android.honeyboard.settingsmon.HoneyBoardSettingsActivity mIsVrOnly=false mSupportsSwitchingToNextInputMethod=false
  mIsDefaultResId=0x7f050006
  Service:
    priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
    ServiceInfo:
      name=com.samsung.android.honeyboard.service.HoneyBoardService
      packageName=com.samsung.android.honeyboard
      enabled=true exported=true directBootAware=true
      permission=android.permission.BIND_INPUT_METHOD
      flags=0x0
      ApplicationInfo:
        name=com.samsung.android.honeyboard.app.HoneyBoardApplication
        packageName=com.samsung.android.honeyboard
        labelRes=0x7f120091 nonLocalizedLabel=null icon=0x7f0f0000 banner=0x0
        className=com.samsung.android.honeyboard.app.HoneyBoardApplication
        processName=com.samsung.android.honeyboard
        taskAffinity=com.samsung.android.honeyboard
        uid=10257 flags=0xb8d83e45 privateFlags=0x2c101140 theme=0x7f13012d
        requiresSmallestWidthDp=0 compatibleWidthLimitDp=0 largestWidthLimitDp=0
        sourceDir=/system/app/HoneyBoard/HoneyBoard.apk
        resourceDirs=[/vendor/overlay/NavigationBarModeSamsungGesturalNoHint/NavigationBarModeSamsungGesturalNoHintOverlay.apk]
        seinfo=platform:targetSdkVersion=29
        seinfoUser=:complete
        dataDir=/data/user/0/com.samsung.android.honeyboard
        deviceProtectedDataDir=/data/user_de/0/com.samsung.android.honeyboard
        credentialProtectedDataDir=/data/user/0/com.samsung.android.honeyboard
        enabled=true minSdkVersion=27 targetSdkVersion=29 versionCode=510109300 targetSandboxVersion=1
        supportsRtl=true
        fullBackupContent=true
        HiddenApiEnforcementPolicy=0
        usesNonSdkApi=false
        allowsPlaybackCapture=true
        ......
        ......
        (太长了,仅截取第一个输入法...)

3.常看当前正在使用的输入法

命令:

adb shell settings get secure default_input_method

输出:

zekylldeMacBook-Pro:~ zekyll$ adb shell settings get secure default_input_method
comease.nie.yosemite/.ime.ImeService

4.切换输入法(设置默认输入法)

命令:

adb shell settings put secure default_input_method com.sohu.inputmethod.sogou/.SogouIME
  • 注意:系统设置中未开启状态的输入法,只要你知道了它的名字,也可以使用这个命令切换使用。

5.附上帮助文档

zekylldeMacBook-Pro:~ zekyll$ 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