Skip to content

Instantly share code, notes, and snippets.

View dilovan's full-sized avatar
🏠
Working at home

Dlovan Bashir Ali dilovan

🏠
Working at home
View GitHub Profile
@dilovan
dilovan / Hidekeyboard
Created January 18, 2019 18:35
android os hide keyboard
// hide keyboard
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);