Example usage for android.content Context INPUT_METHOD_SERVICE

List of usage examples for android.content Context INPUT_METHOD_SERVICE

Introduction

In this page you can find the example usage for android.content Context INPUT_METHOD_SERVICE.

Prototype

String INPUT_METHOD_SERVICE

To view the source code for android.content Context INPUT_METHOD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.inputmethod.InputMethodManager for accessing input methods.

Usage

From source file:Main.java

/**
 * To hide system's keyboard.//from   w w w .  j  a  va 2s .c  o  m
 */
public static void hideSoftInput(Context appContext, View... views) {
    InputMethodManager inputManager = (InputMethodManager) appContext
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    for (View view : views) {
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}

From source file:Main.java

/**
 * Hides the keyboard./*from ww  w.java 2  s  .  co m*/
 * @param view
 */
private static void hideKeyboard(View view) {
    Context context = view.getContext();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

/**
 * Shows the keyboard./*  ww w .j a  v a  2  s . co  m*/
 * @param view
 */
private static void showKeyboard(View view) {
    Context context = view.getContext();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:Main.java

public static void hideSoftKeyboard(Context context, View view) {
    if (null != context && null != view) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from w w  w.  j  av  a 2s . co m
}

From source file:Main.java

private static InputMethodManager getInputMethodManager(Context context) {
    return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:Main.java

public static void hide(final Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }// www.j  a  v  a2 s  .  c  o m
}

From source file:Main.java

public static final void hideKeyBoard(Context context, View view) {
    if (view == null || context == null)
        return;// w w  w . jav  a 2 s  . co m
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void showInputMethodWindow(Activity activity, View view) {
    try {//  ww w  .ja  v  a2s  .  com
        InputMethodManager inputMethodManager = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    } catch (Throwable e) {
    }
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager inputManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus:
    View v = activity.getCurrentFocus();
    if (v == null)
        return;/* www  .j a  v a 2 s  .com*/

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Context context, View view) {
    if (context != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) context.getApplicationContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (inputMethodManager != null) {
            if (view != null) {
                inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }//  ww  w .  j  ava 2  s .  c  om
        }
    }
}