List of usage examples for android.content Context INPUT_METHOD_SERVICE
String INPUT_METHOD_SERVICE
To view the source code for android.content Context INPUT_METHOD_SERVICE.
Click Source Link
From source file:Main.java
/** * Request to hide the soft input window from the context of the window that * is currently accepting input.//from w ww.j a va2 s. co m * * @param activity * The currently activity, which shows the view receives soft * keyboard input. */ public static void hideKeyboard(Activity activity) { if (null == activity) { return; } InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); View v = activity.getCurrentFocus(); if (v != null) { im.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:Main.java
public static void hideSoftKeyboard(View view) { if (view == null) return;/* ww w . j a v a 2 s. co m*/ View mFocusView = view; Context context = view.getContext(); if (context != null && context instanceof Activity) { Activity activity = ((Activity) context); mFocusView = activity.getCurrentFocus(); } if (mFocusView == null) return; mFocusView.clearFocus(); InputMethodManager manager = (InputMethodManager) mFocusView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); manager.hideSoftInputFromWindow(mFocusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
/** * Toggle Soft Input./*from w w w .j a va 2 s .c o m*/ * @param context * @param showFlags */ public static void toggleSoftInput(Context context, int showFlags) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(showFlags, InputMethodManager.HIDE_IMPLICIT_ONLY); }
From source file:Main.java
public static void showKeyboard(Context c, View v) { InputMethodManager mgr = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); }
From source file:Main.java
public static void hideKeyboard(Context c, View v) { InputMethodManager mgr = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromInputMethod(v.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftInput(Context context, EditText edit) { edit.clearFocus();//from w w w . j a va 2 s . co m InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0); }
From source file:Main.java
public static boolean isActive(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); return imm.isActive(); }
From source file:Main.java
public static void closeKeyboard(Dialog dialog) { View view = dialog.getWindow().peekDecorView(); if (view != null) { InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }/*ww w . j a v a 2 s . co m*/ }
From source file:Main.java
public static void toggleKeyboard(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive()) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); }/* w w w. j av a 2 s .c o m*/ }
From source file:Main.java
public static void hideKeyBoard(Activity aty) { ((InputMethodManager) aty.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( aty.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }