安卓:确定从code动态输入法输入法、动态、code

由网友(相信自已)分享简介:你如何确定哪种输入法是当前活动 - 用户可以切换输入法(软键盘)由长pressing上的文本编辑字段 - 从code,一个人如何确定哪种输入法用户选择How do you determine which input method is currently active - A user can change the...

你如何确定哪种输入法是当前活动 - 用户可以切换输入法(软键盘)由长pressing上的文本编辑字段 - 从code,一个人如何确定哪种输入法用户选择

How do you determine which input method is currently active - A user can change the input method (soft keyboard) by long pressing on a text edit field - From code, how does one determine which input method the user has chosen

推荐答案

我知道你可能不需要这个了,但有人可能会想这个问题的答案。您可以使用此行来获得输入法的使用串ID:

I realise you probably don't need this anymore, but someone might want the answer to this. You can use this line to get the String ID of the Input Method in use:

String id = Settings.Secure.getString(
   getContentResolver(), 
   Settings.Secure.DEFAULT_INPUT_METHOD
);

如果你想获得关于当前键盘的更多信息,你可以使用:

If you want to get more information about the current keyboard, you can use:

    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;
        }
    }
阅读全文

相关推荐

最新文章