07-20-2023, 04:30 PM
I'm having troubles with hiding the keyboard on Android 8.
I used this before and it worked for the older androids:
val view = activity.currentFocus
if (view != null) {
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
Android 8 just ignores it and shows the keyboard anyway.
Probably making the input field unfocusable would help, but I really need it to be focusable, so this is not an option.
I used this before and it worked for the older androids:
val view = activity.currentFocus
if (view != null) {
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
Android 8 just ignores it and shows the keyboard anyway.
Probably making the input field unfocusable would help, but I really need it to be focusable, so this is not an option.