如何确定哪种输入法当前处于活动状态-用户可以通过长按文本编辑字段来更改输入法(软键盘)-从代码中,如何确定用户选择了哪种输入法
发布于 2011-04-20 06:10:52
我知道你可能不再需要这个了,但是可能有人想要这个问题的答案。您可以使用下面这一行来获取正在使用的输入法的字符串ID:
String id = Settings.Secure.getString(
getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD
);如果您想获得有关当前键盘的更多信息,您可以使用:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList();
final int N = mInputMethodProperties.size();
for (int i = 0; i < N; i++) {
InputMethodInfo imi = mInputMethodProperties.get(i);
if (imi.getId().equals(Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD))) {
//imi contains the information about the keyboard you are using
break;
}
}https://stackoverflow.com/questions/3380234
复制相似问题