rbd
rbd

Reputation: 187

Android get available input languages

I'm trying to get the available input devices on Android, in order to do that I'm using the InputMethodManager and using the API of getEnabledInputMethodList() as follows:

InputMethodManager inputMgr = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> inputMethodList = inputMgr.getEnabledInputMethodList();

    for (InputMethodInfo method : inputMethodList) {
        List<InputMethodSubtype> subMethods = inputMgr.getEnabledInputMethodSubtypeList(method, true);
        for (InputMethodSubtype submethod : subMethods) {
            if (submethod.getMode().equals("keyboard")) {    //Ignore voice input method
                String localeString = submethod.getLocale();
                                Locale locale = new Locale(localeString);
                                String currentLanguage = locale.getLanguage();
                                //do something...
            }
        }
    }

However, although I've got many more input languages available on my LG G3 and MEIZU M2, this API returns only 1 input language - English. It seems that this API works as expected only on Google Nexus phones.

Has anyone tried to do the same and succeeded?

P.S I've already read the solution on this thread but it doesn't help much: how to get user keyboard language

Upvotes: 0

Views: 895

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93561

There is no way to do this. A keyboard doesn't report to Android the list of languages it supports.

In fact, most keyboards keep the input language separate from the phone's locale, in order to switch without resetting the UI of the entire phone. So the OS has no idea what languages a keyboard can write in or is currently writing in.

Upvotes: 1

Related Questions