ime enable:使输入法可用
ime set :设置输入法
一、命令:切换到自定义的输入法,
shell@android:/ $ ime enable mycom.speaking.application/com.voice.recognition.keyboard.utils.MyImeService
shell@android:/ $ ime set mycom.speaking.application/com.voice.recognition.keyboard.utils.MyImeService
运行结果:
原来的界面,显示的是三星默认的输入法
命令执行后,显示为自定义的输入法
二、切换为三星默认的输入法
shell@android:/ $ ime enable com.sec.android.inputmethod/.SamsungKeypad
shell@android:/ $ ime set com.sec.android.inputmethod/.SamsungKeypad
运行后的结果:由原来自定义的输入法切换为了三星的输入法
注:
1.参考资料:https://android.stackexchange.com/questions/47948/how-to-change-input-method-with-ime-command
2.获取输入法的名字
List<InputMethodInfo> InputMethods = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).getEnabledInputMethodList();
String NewInputMethodName = "";
for (int i = 0; i < InputMethods.size(); i++) {
InputMethodInfo inputMethod = InputMethods.get(i);
NewInputMethodName = inputMethod.getId();
System.out.println("input method " + i + " ...id ..." + inputMethod.getId());
}