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

private static void hideSoftInput(Context ctx, IBinder token) {
    if (token != null) {
        InputMethodManager im = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
        im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from ww w  . jav  a2  s. c  om*/
}

From source file:Main.java

public static void closeSoftKeyboard(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.  j a va 2 s . c  o  m
}

From source file:Main.java

public static void hideSoftKeyBoard(EditText etInput) {
    InputMethodManager inputManager = (InputMethodManager) etInput.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(etInput.getWindowToken(), 0);
}

From source file:Main.java

public static void openWindowSoftKeyboard(View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInputFromWindow(view.getApplicationWindowToken(),
            InputMethodManager.SHOW_FORCED, 0);
}

From source file:Main.java

public static void hideKeyBoard(Context context, View view) {
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from  w w  w. j ava 2  s  .c  o  m
}

From source file:Main.java

public static void hidenInput(Activity ctx) {
    // TODO Auto-generated method stub

    InputMethodManager imm = ((InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE));

    imm.hideSoftInputFromWindow(ctx.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

}

From source file:Main.java

public static void showKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
        }/*from  www.  ja va  2s . c  om*/
    }
}

From source file:Main.java

public static boolean hideInputSoft(View trigger) {
    InputMethodManager inputMethodManager = (InputMethodManager) trigger.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    return inputMethodManager.hideSoftInputFromWindow(trigger.getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void showSoftKeyBoard(EditText etInput) {
    InputMethodManager inputManager = (InputMethodManager) etInput.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    //            inputManager.showSoftInput(etInput, 0);
}

From source file:Main.java

public static void showSoftInput(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, 2);
}