Java tutorial
//package com.java2s; import android.content.Context; import android.os.Handler; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void setSoftInputVisible(final View content, boolean visible, int delay) { final InputMethodManager imm = (InputMethodManager) content.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (visible) { if (delay > 0) { new Handler().postDelayed(new Runnable() { @Override public void run() { imm.showSoftInput(content, 0); } }, delay); } else { imm.showSoftInput(content, 0); } } else { if (delay > 0) { new Handler().postDelayed(new Runnable() { @Override public void run() { imm.hideSoftInputFromWindow(content.getWindowToken(), 0); } }, delay); } else { imm.hideSoftInputFromWindow(content.getWindowToken(), 0); } } } }