how to programmatically hide android soft keyboard

Solutions on MaxInterview for how to programmatically hide android soft keyboard by the best coders in the world

showing results for - "how to programmatically hide android soft keyboard"
Clara
29 Nov 2020
1    private void closeSoftKeyboard() 
2    { 
3    	//If using a fragment use getActivity().getCurrentFocus()
4        View v = this.getCurrentFocus(); 
5  
6  		// If Soft Keyboard is visible, it will be hide
7        if (v != null) { 
8          //If using a fragment use getActivity().getSystemService(...)
9            InputMethodManager inputManager 
10                = (InputMethodManager) 
11                    getSystemService(Context.INPUT_METHOD_SERVICE); 
12            inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0); 
13        } 
14    }