Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.Context; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; public class Main { public static void hideSoftInputView(Activity activity) { if (activity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { InputMethodManager manager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { manager.hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } } }