linoidkl
linoidkl

Reputation: 11

Cannot catch back-button. "The input has been finished in ImeInputStage."

I have an AppCompatActivity where I programmatically toggle the softinput. There is only one scenario where my keyboard open/close boolean is not set properly because I cannot intercept the back-button event. This event closes the keyboard when executed.

The following is printed when pressing the on-screen back button when a keyboard is opened.

I/ViewRootImpl@af03171[MainActivity]: The input has been finished in ImeInputStage.
  1. I've tried all the toggleSoftInput variants/flags I could find to pray it would somehow circumvent the issue
  2. I tried to catch the press with "dispatchKeyEvent", "backPressed", "onKeyUp", "onKeyDown", "onKeyPreIme" with no luck.

And as the message says the event is finishing somewhere else. I just can't find anything on the web to realize the functionality I need for my application.

In addition, this is my toggle function.

public void toggleSoftInput() {
        InputMethodManager imm = (InputMethodManager) getAndroidContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
        keyboardOpened = !keyboardOpened;
}

Edit: I've searched over any resource I could find and still haven't been able to resolve this edge case in my application. Any pointers are greatly appreciated.

Upvotes: 1

Views: 373

Answers (0)

Related Questions