Last active
February 22, 2018 02:47
-
-
Save turastory/0381120822deabefa5a9bea96fca4dc0 to your computer and use it in GitHub Desktop.
Android - Show keyboard safely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void showKeyboard() { | |
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
if (imm != null) { | |
editText.postDelayed(() -> { | |
editText.requestFocus(); | |
imm.showSoftInput(editText, 0); // might be flags | |
}, 300); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment