Hide soft keyboard in Android

/** * This method is used to hide soft keyboard. * * @param activity */ public static void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View f = activity.getCurrentFocus(); if (null != f && null != f.getWindowToken() && EditText.class.isAssignableFrom(f.getClass())) imm.hideSoftInputFromWindow(f.getWindowToken(), 0); else activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.