0

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. enter image description here

    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?

  • Did you try using [IME Option Done](https://stackoverflow.com/questions/2004344/how-do-i-handle-imeoptions-done-button-click) – Nitish Nov 25 '21 at 13:01
  • That's used to control the return button on the keyboard but i cannot access the send button view due to SDK limited control so I'm basically working with nothing here. – Mohamed Eweidat Nov 25 '21 at 13:12

0 Answers0