I develop an sms sender app and I wanna know language that user uses. so, when user types a message how can I know language that he/she uses?
Asked
Active
Viewed 7,503 times
3 Answers
10
get the input type manager by using:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
then , choose what to get from it using the next methods :
together with this to get the locale of the input type:
http://developer.android.com/reference/android/view/inputmethod/InputMethodSubtype.html#getLocale()

android developer
- 114,585
- 152
- 739
- 1,270
-
1hi guy, but this solution available in API 11, and I want to use that for android 2.3! how to use your idea for lower versions before API 11. – NrNazifi Feb 12 '13 at 07:37
-
good point. sorry for missing it . maybe it's possible to read from the android code and see if there is a way to overcome it for older versions . – android developer Feb 12 '13 at 09:33
-
Google keyboard does not return language code.. what to do about that? any solution? – axita.savani Mar 02 '22 at 12:39
4
You can get keyboard language by first detecting the locale of device keyboard and then getting the Locale
object from it. For example,
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
String localeString = ims.getLocale();
Locale locale = new Locale(localeString);
String currentLanguage = locale.getDisplayLanguage();
Here, currentLanguage
will give your keyboard language. Hope this helps.

AndyN
- 1,742
- 1
- 15
- 30
-
-
Google keyboard, Kika keyboard from Xiami does not return language code.. what to do about that? any solution? – axita.savani Mar 02 '22 at 12:41
0
It's impossible to retrieve the current keyboard language. Android does not allow to retrieve the current configured language, there aren't any API.

StarsSky
- 6,721
- 6
- 38
- 63