Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.Context; import android.view.inputmethod.InputMethodManager; public class Main { public static void hiddenKeyboard(Class className, Context context, Activity activity) { try { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (activity.getCurrentFocus() != null) { if (activity.getCurrentFocus().getWindowToken() != null) { imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } } catch (Exception e) { e.printStackTrace(); } } }