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 showKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
    }/*from ww w . j  av a 2 s  .c  o m*/
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void toggleKeyboard(Activity activity, View v) {

    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}

From source file:Main.java

public static void showKeyBoard(Activity activity, View view) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

From source file:Main.java

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

From source file:Main.java

public static void openSoftInput(EditText et) {
    InputMethodManager inputMethodManager = (InputMethodManager) et.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(et, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideSoftInput(EditText et) {
    InputMethodManager inputMethodManager = (InputMethodManager) et.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(et.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

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

From source file:Main.java

public static void showInput(EditText editText) {
    InputMethodManager inputManager = (InputMethodManager) editText.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(editText, 0);
}