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 showSoftInput(Context context, EditText editText) {
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputManager != null) {
        inputManager.showSoftInput(editText, 0);
    }/*  www. ja  va2  s.c om*/
    editText.requestFocus();
}

From source file:Main.java

public static boolean showSoftInput(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.showSoftInput(view, 2);
}

From source file:Main.java

/**
 * Hide the soft keyboard.//from w ww  . j a va2 s . c om
 */
protected static void doHideKeyboard(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 hiddenSoftKeyBoard(Context context) {
    try {/*from   www. jav a 2 s.  c  o  m*/
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getApplicationWindowToken(), 0);
    } catch (Exception e) {

    }
}

From source file:Main.java

public static void showSoftKeyboard(Context context, EditText editText) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    editText.requestFocus();//from  w w  w . j  a  v a 2  s . com
}

From source file:Main.java

public static void showSoftInput(View view) {
    // TODO Auto-generated method stub
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);

}

From source file:Main.java

public static void showSoftKeyPad(Context context, View view) {
    try {//  www. ja  v  a  2 s . c o m
        InputMethodManager inputManager = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.showSoftInput(view, InputMethodManager.RESULT_UNCHANGED_SHOWN);
    } catch (Throwable ex) {
    }
}

From source file:Main.java

public static void dismissSoftKeyboard(Context context, EditText editText) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    editText.clearFocus();/*  ww  w  . j a  va2  s  .co  m*/
}

From source file:Main.java

public static void hideKeyboard(Activity activity, EditText edt) {
    final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (edt != null) {
        imm.hideSoftInputFromWindow(edt.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } else {/* w w  w  . ja  v  a  2s.c o  m*/
        if (activity.getCurrentFocus() != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}

From source file:Main.java

public static void showKeyboard(Context context, View view) {
    try {//from  w ww  . ja v a2s  .  c om
        InputMethodManager inputManager = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.toggleSoftInputFromWindow(view.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED,
                0);
        view.requestFocus();
    } catch (Exception ex) {
    }
}