Android开发时,调试谷歌开源输入法时,debug是需要手动修改默认输入,因为是临时的,所以考虑通过adb命令修改。
正文
虽然这里是临时修改默认输入法,但也记录一下源码中如果修改输入法配置。
代码
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
通过关键字input_method
<string name="def_input_method" translatable="false">com.google.android.inputmethod.pinyin/.PinyinIME</string> <string name="def_enabled_input_methods" translatable="false">com.google.android.inputmethod.pinyin/.PinyinIME</string>
把包名
com.google.android.inputmethod.pinyin/.PinyinIME
改为自己的
com.biumall.ime/.PinyinIME
adb
上面的只是通过代码修改,但是临时需要,可以通过adb命令。
查看当前设置的输入法
adb shell settings get secure default_input_method
例子
C:\Users\admin>adb shell settings get secure default_input_method com.biumall.ime/.PinyinIME
显示所有的输入法
adb shell ime list -s
例子
C:\Users\admin>adb shell ime list -s com.biumall.ime/.PinyinIME
设置默认输入法
adb shell ime set <input_method_id>
input_method_id是输入法的服务启动包名路径,具体看如下。
例子
adb shell ime set com.biumall.ime/.PinyinIME
启用新的输入法
adb shell ime enable <input_method_id>
例子
adb shell ime enable com.biumall.ime/.PinyinIME
这个命令就是会拉起com.biumall.ime/.PinyinIME
PinyinIME是一个服务类
禁用输入法
adb shell ime disable <input_method_id>
跟上面一样,懒得举例了。
