1

Android Hide keyboard when changing fragments

view story
linux-howto

http://stackoverflow.com – When I change fragments. I am using this to close the keyboard because there is an EditText field on the screen. I just feel like there has to be a better way, but I havent found anything on detecting if the keyboard is on the screen. Activity activity = getActivity(); InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); try { inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); } catch (Exception e) { } (HowTos)