Reputation: 11
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.
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