Java tutorial
//package com.java2s; import android.app.Activity; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void hidekeyboard(Activity act) { InputMethodManager imm = ((InputMethodManager) act.getSystemService(Activity.INPUT_METHOD_SERVICE)); if (imm.isActive()) { View focusView = act.getCurrentFocus(); if (focusView != null) { imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0); } } } }