Android hide keyboard

public void hideKeyboard(Context context, View view) {
    InputMethodManager inputMethodManager = 
                       (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
//Call below code from inside an Activity.
hideKeyboard(this, view);
hideKeyboard(this, getCurrentFocus());
hideKeyboard(this, getWindow().getDecorView());
hideKeyboard(this, findViewById(android.R.id.content));
Content Protection by DMCA.com
Please Share