Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Context; import android.os.IBinder; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void hideSoftInput(Activity activity) { View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { IBinder windowToken = currentFocus.getWindowToken(); if (windowToken != null) { InputMethodManager manager = (InputMethodManager) (activity .getSystemService(Context.INPUT_METHOD_SERVICE)); if (manager != null) { manager.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); } } } } }