鉴于以下代码:
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> inputMethods = imm.getEnabledInputMethodList();
for(InputMethodInfo method : inputMethods){
String name = method.loadLabel(activity.getPackageManager()).toString();
new InfoDialog(activity,name).show();
//imm.setInputMethod(token, id);
}
我的设备中安装了两个输入法:三星键盘和 Google手写输入。我试图做的是使用setInputMethod
在这两个键盘之间切换。
示例:
imm.setInputMethod(<Samsung Keyboard>);
或
imm.setInputMethod(<Google Handwriting Input>);
怎么做?有什么想法吗?
答案 0 :(得分:2)
嗯,没有办法被动地改变它,而是提示用户这样做
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
imeManager.showInputMethodPicker();
但是,如果您拥有系统权限,则可以将其更改为:
Settings.Secure.putString(resolver, Settings.Secure.ENABLED_INPUT_METHODS, "com.package.to.keyboard/.full.path");
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, "com.package.to.keyboard/.full.path");