Thunder Storm Thunder Storm - 2 months ago 36
Android Question

How to get current InputMethodService

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?

Answer

You cannot "get" the InputMethodService, as it is running in a different process than yours.