Java tutorial
//package com.java2s; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void showSoftInput(Context context, View focusView) { InputMethodManager imm = from(context); if (imm.isActive()) { imm.showSoftInput(focusView, InputMethodManager.SHOW_IMPLICIT); } } public static InputMethodManager from(Context context) { return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); } public static boolean isActive(Context context) { InputMethodManager imm = from(context); return imm.isActive(); } public static boolean isActive(Context context, View focusView) { InputMethodManager imm = from(context); return imm.isActive(focusView); } }