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

public static InputMethodManager getInputMethodManager(Activity activity) {
    return (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:Main.java

public static void hideKeyboard(Context context, IBinder token) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(token, 0);
}

From source file:Main.java

public static void hideKeyboard(Activity _activity, View _view) {
    InputMethodManager inputMethodManager = (InputMethodManager) _activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(_view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideSoftKeyboard(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void showSoftKeyBroad(Context context, EditText editText) {
    InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    // only will trigger it if no physical keyboard is open
    mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}

From source file:Main.java

public static void hideKeyboard(Context context, View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void showKeyboard(Context context, View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (view.requestFocus()) {
        inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    }/*www.  j ava 2s  . co  m*/
}

From source file:Main.java

public static void toggleKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from ww  w  .ja v a  2s  .co m*/
}

From source file:Main.java

public static void closeSoftInput(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null && ((Activity) context).getCurrentFocus() != null) {
        inputMethodManager.hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }// ww w.  ja v  a 2s . co  m
}