Java tutorial
//package com.java2s; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { /** * Force hide soft keyboard with flag : InputMethodManager.HIDE_NOT_ALWAYS. * @param context Context to get system service input method. * @param viewBinder View has current focus. Can achived by View.getWindowToken(). */ public static void hideKeyboard(Context context, View viewBinder) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(viewBinder.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } /** * Force hide soft keyboard with specific flag. * @param context Context to get system service input method. * @param viewBinder View has current focus. Can achived by View.getWindowToken(). * @param flags InputMethodManager flags. */ public static void hideKeyboard(Context context, View viewBinder, int flags) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(viewBinder.getWindowToken(), flags); } }