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(Context context, View v) {
    v.requestFocus();/*  w  w  w  .  ja v a  2  s . com*/
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
}

From source file:Main.java

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

From source file:Main.java

public static void openKeyboard(Activity activity) {

    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void changeKeyBoard(Context context, EditText editText) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    editText.setFocusable(true);// w  ww.j av a2 s .  com
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    if (imm.isActive()) {
        // imm.hideSoftInputFromWindow(getCurrentFocus()
        // .getWindowToken(),
        // InputMethodManager.HIDE_NOT_ALWAYS);
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:Main.java

public static void showKeyboard(Context context, View view) {
    imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, 0);/*from   w w w . j ava 2s . c  o m*/
    //        imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

From source file:Main.java

public static void closeInput(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null && activity.getCurrentFocus() != null) {
        inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from  ww w  . java 2 s .  c om*/
}

From source file:Main.java

public static void closeKeyBoard(Context context, View view) {
    view.clearFocus();/*from   w  ww  . jav a  2 s.  c om*/
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Context context, View edt) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null)
        imm.hideSoftInputFromWindow(edt.getWindowToken(), 0);
}

From source file:Main.java

public static boolean hideInputMethod(View view) {
    final InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/*from   www .  ja  v  a 2 s. co  m*/
    return false;
}

From source file:Main.java

public static void showKeyBoard(Context context, View view) {
    view.requestFocus();/* w w w .  ja  v  a  2 s .c  o m*/
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}