Here you can find the source of closeSoftKeyboard(Activity activity)
public static void closeSoftKeyboard(Activity activity)
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Context; import android.os.IBinder; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void closeSoftKeyboard(Activity activity) { if (activity == null) return; InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View currentView = activity.getCurrentFocus(); if (currentView != null) { IBinder token = currentView.getWindowToken(); if (token != null) { inputManager.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w . j av a 2 s.c o m*/ } } }