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
/** * Hides the soft keyboard/*from ww w . j a va2 s . c o m*/ * * @param activity The reference of the activity displaying the keyboard */ public static void hide(@NonNull final Activity activity) { final InputMethodManager iManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); final View view = activity.getCurrentFocus(); if (view != null && iManager != null) { iManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:Main.java
public static void hideSoftInputView(Activity activity) { if (activity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { InputMethodManager manager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { manager.hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }//from w ww .java 2s . c om } }
From source file:Main.java
/** * Toggles the SoftKeyboard Input be careful where you call this from as if you want to * hide the keyboard and its already hidden it will be shown * * @param context the context / usually the activity that the view is being shown within *//* w w w .j av a2 s . co m*/ public static void toggleKeyboard(Context context) { InputMethodManager imm = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)); imm.toggleSoftInput(0, 0); }
From source file:Main.java
public static void hideSoftInputFromWindow(Context context, View... views) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (views != null && views.length > 0) { for (View view : views) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }//w ww. j a va 2 s . co m } }
From source file:Main.java
/** * Hides the keyboard//from ww w.j a v a2 s. co m * @param activity The activity currently active */ public static void hideKeyboardFromActivity(Activity activity) { View v = activity.getCurrentFocus(); if (v != null) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.CUPCAKE) public static void hideSoftInput(Activity activity) { View view = activity.getWindow().peekDecorView(); if (view != null) { InputMethodManager inputmanger = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0); }//w ww. j a va 2 s .c om }
From source file:Main.java
/** * Force hide soft keyboard with flag : InputMethodManager.HIDE_NOT_ALWAYS. * @param context Context to get system service input method. * @param viewBinder View has current focus. Can achived by View.getWindowToken(). *///from ww w . j a va 2 s. c o m public static void hideKeyboard(Context context, View viewBinder) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(viewBinder.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static void showInputMethod(Context context) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
/** * Magic to close the soft keyboard./*from w w w .ja v a 2 s . co m*/ * * See http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard * * @param context The context. * @param focusedView The focused view. */ public static void closeSoftKeyboard(Context context, View focusedView) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(focusedView.getWindowToken(), 0); }
From source file:Main.java
/** * <pre>/* ww w .j a v a 2 s . c o m*/ * Show keyboard, typically in an activity having {@link EditText}. * </pre> * @param focusedView typically an {@link EditText} */ public static void showKeyboard(View focusedView) { focusedView.requestFocus(); InputMethodManager inputMethodManager = ((InputMethodManager) getCurrentContext() .getSystemService(Context.INPUT_METHOD_SERVICE)); inputMethodManager.showSoftInput(focusedView, InputMethodManager.SHOW_FORCED); }