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 Activity activity) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) { return;//from w w w. j av a2 s . com } View view = activity.getCurrentFocus(); if (view == null) { view = new View(activity); } imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:com.activiti.android.ui.utils.UIUtils.java
public static void hideKeyboard(Activity activity, View v) { InputMethodManager mgr = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(v.getWindowToken(), 0); }
From source file:Main.java
/** * Hide soft key board.// w w w . ja va2 s . c o m * * @param activity the activity */ public static void hideSoftKeyBoard(Activity activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { IBinder windowToken = currentFocus.getWindowToken(); inputManager.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); } else { activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); } }
From source file:Main.java
/** * Close the soft key board// w w w . j a va 2s.c om */ public static void closeSoftKeyBoard(Activity pActivity) { if (pActivity != null) { final InputMethodManager inputMethodManager = (InputMethodManager) pActivity .getSystemService(Activity.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { final View currentFocus = pActivity.getCurrentFocus(); if (currentFocus != null) { inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); } } } }
From source file:Main.java
public static void hideSoftKeyboard(final Activity activity, final View input) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { if (input != null) { IBinder windowToken = input.getWindowToken(); if (windowToken != null) { inputMethodManager.hideSoftInputFromWindow(windowToken, 0); }//from ww w . j a v a 2s. c om } } }
From source file:com.app.opencity.activities.MainActivity.java
public static void hideKeyboard(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }
From source file:Main.java
/** * Chiude la tastiera virtuale.//from ww w . j av a 2s. com * * @param activity Attività. */ public static void hideSoftInput(Activity activity) { View view; InputMethodManager inputMgr; if (activity == null) { throw new NullPointerException("Argument activity is null."); } view = activity.getCurrentFocus(); if (view == null) { return; } inputMgr = (InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); inputMgr.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void hideKeyboard(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); //Find the currently focused view, so we can grab the correct window token from it. View view = activity.getCurrentFocus(); //If no view currently has focus, create a new one, just so we can grab a window token from it if (view == null) { view = new View(activity); }//from w w w. j a v a2 s . c o m inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftKeyBoard(Context context, final View... views) { try {/*from w w w .ja va 2 s .c o m*/ final InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); new Handler().postDelayed(new Runnable() { @Override public void run() { try { if (views != null) { for (View view : views) { if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } } } catch (Exception e) { } } }, 200); } catch (Exception e) { } }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void hideKeyboardFromActivity(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); View view = activity.getCurrentFocus(); if (view == null) { view = new View(activity); }/*w ww. j a va 2 s. co m*/ inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }