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 void showInputSoftFromWindowMethod(Context context, View view) {
    try {//from  w  ww.j  a  va 2s  .c  o m
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void closeInputMethodWindow(Activity activity) {
    try {/*from   w  w  w.  ja v a  2s.  c o  m*/
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Throwable th) {
        th.printStackTrace();
    }
}

From source file:Main.java

public static void closeKeyBoard(EditText editText, Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideSoftKeyboard(Context context, IBinder windowToken) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void closeKeyboard(EditText view) {
    view.clearFocus();/*from   w  w  w .  ja v a 2  s.c o m*/
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}

From source file:Main.java

public static void hideSoftInput(Activity mActivity, EditText editText) {
    InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}