android keyboard how can hide code example

Example 1: android hide keyboard

public void hideKeyboard(Context context, View view) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

// call from inside an Activity...
hideKeyboard(this, view);
hideKeyboard(this, getCurrentFocus());
hideKeyboard(this, getWindow().getDecorView());
hideKeyboard(this, findViewById(android.R.id.content));

Example 2: android activity keyboard hide

<activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />

Tags:

Java Example