How to programmatically get current keyboard language on an Android device

前端 未结 2 1642
夕颜
夕颜 2020-12-10 17:35

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 eng

2条回答
  •  眼角桃花
    2020-12-10 17:58

    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

提交回复
热议问题