Skip to content

Instantly share code, notes, and snippets.

@turastory
Last active February 22, 2018 02:47
Show Gist options
  • Save turastory/0381120822deabefa5a9bea96fca4dc0 to your computer and use it in GitHub Desktop.
Save turastory/0381120822deabefa5a9bea96fca4dc0 to your computer and use it in GitHub Desktop.
Android - Show keyboard safely
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