Skip to content

Instantly share code, notes, and snippets.

@kobeumut
Created August 21, 2017 07:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobeumut/40769635b4370e238a79b4dc3b3c57ce to your computer and use it in GitHub Desktop.
Save kobeumut/40769635b4370e238a79b4dc3b3c57ce to your computer and use it in GitHub Desktop.
Close opened keyboard on Android programatically
//For Kotlin
val inputManager:InputMethodManager =getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(currentFocus.windowToken, InputMethodManager.SHOW_FORCED)
//For Java
InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment