Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.os.Handler; import android.view.Window; import android.view.inputmethod.InputMethodManager; public class Main { public static void hideSoftKeyBoard(final Window window) { new Handler().postDelayed(new Runnable() { @Override public void run() { if (window.getCurrentFocus() != null) { InputMethodManager inputManager = (InputMethodManager) window.getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(window.getCurrentFocus().getWindowToken(), 0); } } }, 200); } }