Search code examples
javaandroidlocale

Getting the current soft keyboard locale


I am unable to get current soft keyboard locale.

I tried to get

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();

String locale = ims.getLocale();
String tag = ims.getLanguageTag();

This always returns an empty string. getNameResId() always returns the same value. Is there any other way to get soft keyboard's locale?


Solution

  • If you mean the language the keyboard is actually showing- you can't. That isn't tied to the system Locale, and there's no API to retrieve it.

    The whole InputMethodSubtype thing is basically not used anywhere. And even if it was, it wouldn't give a full locale or language (it was meant to differentiate japanes, chinese, etc. Not english from spanish which use the same keytboard).