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 showImm(Context context, View view) {
    if (null == context) {
        return;/*ww  w  .j av  a 2s.co m*/
    }
    if (view != null) {
        InputMethodManager imm = ((InputMethodManager) (context
                .getSystemService(Context.INPUT_METHOD_SERVICE)));
        imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    }
}

From source file:Main.java

public static void showSoftInput(Context context, EditText edit) {
    edit.setFocusable(true);//from   w  w w. j a  v  a  2 s.  co m
    edit.setFocusableInTouchMode(true);
    edit.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, 0);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    View view = activity.getCurrentFocus();
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (view == null) {
        return;//from   w  w  w  .j ava2  s.  c o  m
    }

    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null && activity.getCurrentFocus() != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
            activity.getCurrentFocus().clearFocus();
        }/*  w ww .j  a  va2 s. c  om*/
    }
}

From source file:Main.java

public static void showSoftInput(Context context, final EditText et) {
    if (context == null || et == null) {
        return;//from  www .  j  av  a 2  s.  com
    }
    InputMethodManager imm = (InputMethodManager) et.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    imm.showSoftInput(et, InputMethodManager.SHOW_FORCED);
}

From source file:Main.java

public static void showKeyboard(Context context) {
    Activity activity = (Activity) context;
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
        imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from w ww  . j  a v  a2s.c  o m*/
}

From source file:Main.java

public static void clearFocusAndHideKeyboard(Context context, EditText edtText) {
    edtText.clearFocus();//from   www  .j av  a2  s  .c om
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(edtText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideKeyboard(Context context) {
    Activity activity = (Activity) context;
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive() && activity.getCurrentFocus() != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
        }/*from  www.j  a  va  2 s . c o m*/
    }
}

From source file:Main.java

public static void onActive(Context context, EditText et) {
    if (et == null)
        return;/*from  w  w w.j ava  2  s  .  co m*/

    et.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(et, 0);

}

From source file:Main.java

public static void showSoftKeyborad(Activity context, EditText et) {
    if (context == null)
        return;/*from   w w  w  . j  a v a2 s .  c  o m*/
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(et, InputMethodManager.SHOW_FORCED);
}