Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; public class Main { public static void hideKeyboard(Activity activity, EditText edt) { final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (edt != null) { imm.hideSoftInputFromWindow(edt.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } else { if (activity.getCurrentFocus() != null) { imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } } }