Get keyboard language or detect user input language in Android

后端 未结 5 1219
Happy的楠姐
Happy的楠姐 2020-12-15 09:41

Problem Description

I\'m trying to detect current selected language of the keyboard. For that purpose I use following code:

Code

/* Return t         


        
5条回答
  •  难免孤独
    2020-12-15 09:53

    1st Method

    To get the selected language of your device. This might help u

    Locale.getDefault().getLanguage()        ---> en     
    Locale.getDefault().getISO3Language()    ---> eng
    Locale.getDefault().getCountry()         ---> US
    Locale.getDefault().getISO3Country()     ---> USA
    Locale.getDefault().toString()           ---> en_US
    Locale.getDefault().getDisplayLanguage() ---> English
    Locale.getDefault().getDisplayCountry()  ---> United States
    Locale.getDefault().getDisplayName()     ---> English (United States)
    

    2nd Method

    You can extract the language from the current locale. You can extract the locale via the standard Java API, or by using the Android Context. For instance, the two lines below are equivalent:

    String locale = context.getResources().getConfiguration().locale.getDisplayName();
    String locale = java.util.Locale.getDefault().getDisplayName();
    

提交回复
热议问题