What I'm trying to achieve is whenever the keyboard is presented and the user types a string in the input field and hits send then the message sends and that's the behavior on Google Pixel but on Samsung the keyboard dismisses without sending the message and once the keyboard is dismissed then the user can click the send button. Now I added a piece of code to make it so that whenever the user touches anywhere else on the screen, the keyboard dismisses but it seems to be breaking only on Samsung devices.
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (currentFocus != null) {
val imm = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(this.currentFocus?.windowToken, 0)
}
return super.dispatchTouchEvent(ev)
}
Any idea how can this be fixed?