List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:Main.java
public static void hideSoftKeyBoard(final Window window) { new Handler().postDelayed(new Runnable() { @Override//from ww w .j ava 2s . co m public void run() { if (window.getCurrentFocus() != null) { InputMethodManager inputManager = (InputMethodManager) window.getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(window.getCurrentFocus().getWindowToken(), 0); } } }, 200); }
From source file:Main.java
public static void dismissKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE); if (imm.isAcceptingText()) { // verify if the soft keyboard is open imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }//w w w. jav a 2s.c o m }
From source file:Main.java
static public void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View focus = activity.getCurrentFocus(); if (focus != null) imm.hideSoftInputFromWindow(focus.getWindowToken(), 0); }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null && activity.getWindow().getCurrentFocus() != null) { imm.hideSoftInputFromWindow(activity.getWindow().getCurrentFocus().getWindowToken(), 0); }/*w w w.j ava 2 s .c o m*/ }
From source file:Main.java
/** * Hide soft keyboard/*ww w . ja va2s . com*/ * @param activity The activity */ public static void hideSoftKeyboard(Activity activity) { final InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); //noinspection ConstantConditions inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }
From source file:Main.java
public static void hideKeyboard(Context context) { Activity activity = (Activity) context; if (activity != null) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive() && activity.getCurrentFocus() != null) { imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }// ww w. j av a2 s . co m } }
From source file:Main.java
public static void hideKeyboard(Activity activity) { if (activity == null || activity.getCurrentFocus() == null) { return;/* w w w . j a va 2 s.c o m*/ } InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); } }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { InputMethodManager localInputMethodManager = (InputMethodManager) activity.getSystemService("input_method"); IBinder localIBinder = activity.getWindow().getDecorView().getWindowToken(); localInputMethodManager.hideSoftInputFromWindow(localIBinder, 0); }
From source file:Main.java
public static void closeSoftKeyboard(Context context) { if (context == null || !(context instanceof Activity) || ((Activity) context).getCurrentFocus() == null) { return;/* w w w . j a v a 2 s . c o m*/ } try { View view = ((Activity) context).getCurrentFocus(); InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); view.clearFocus(); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void hideInputMethodManager(Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View v = activity.getCurrentFocus(); if (imm != null && v != null) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }/*from w ww . j av a 2s . c o m*/ }