如何在Android和IOS中检测键盘语言?
使用Cordova或Javascript
任何其他方式
请帮助!
我不知道如何在Cordova中使用它,但是对于Kotlin(Android),您可以使用:
public static String getKeyboardLanguage(Context context) {
String locale;
try {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
locale = ims.getLocale();
if (locale.trim().isEmpty()) {
locale = Locale.getDefault().getLanguage();
}
} catch (Exception e) {
locale = Locale.getDefault().getLanguage();
_Log(TAG, Log.getStackTraceString(e));
}
return locale;
}
希望它以正确的方式引导您。