Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current InputMethodService

Tags:

android

ime

How can I get the InputMethodService of the default InputMethod?

I already tried this but I don't know how to get the InputMethodService by an InputMethodInfo:

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;
    }
}

Are there any other solutions I overlooked?

like image 212
ThunderStorm Avatar asked Apr 28 '26 17:04

ThunderStorm


1 Answers

If by saying "get" you mean get it's id, and you want to know the id of the currently selected (chosen as default) here is the way:

    String currentKeyboard =  Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
like image 145
Maxime Claude Avatar answered Apr 30 '26 07:04

Maxime Claude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!