Skip to content Skip to sidebar Skip to footer

How To Programmatically Get Current Keyboard Language On An Android Device

I am writing an application which is using dictionaries. I want to switch between dictionaries any time user change input language. For example if the typing language is english wo

Solution 1:

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

InputMethodSubtypeims= imm.getCurrentInputMethodSubtype();

Stringlocale= ims.getLocale();

You can try this code to get Current Keyboard Language regional code.

Solution 2:

It is possible

imm.getCurrentInputMethodSubtype();

to return you null value. In this case you should check language of android system like this

Locale.getDefault().getLanguage()        ---> en     

otherwise you will receive NullPointerException

Post a Comment for "How To Programmatically Get Current Keyboard Language On An Android Device"