Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { /** * This method hides the keyboard * * @param activity * Active activity */ public static void hideKeyboard(Activity activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View view = activity.getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }