I am writing an application which is using a edit text .i want to know whats users input language in oncreate method or when keyboard input type changes. Is there any way to set a listener to get that change? All the answer i found were about locale and not about input language. I don't want to handle locale, locale has no effect in application, the input language does. i used this codes.
private void printInputLanguages() {
List<InputMethodInfo> ims = imm.getEnabledInputMethodList();
for (InputMethodInfo method : ims) {
List<InputMethodSubtype> submethods = imm
.getEnabledInputMethodSubtypeList(method, true);
for (InputMethodSubtype submethod : submethods) {
if (submethod.getMode().equals("keyboard")) {
String currentLocale =
submethod.getLocale();
tv.setText(currentLocale);
Log.i("sara", "Available input method locale: "
+ currentLocale);
}
}
}
}
and this codes but none of them wasnt help full.
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();
thanks for ur helps.