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 toggleSoftKeyboardState(Context context) {
    ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
            .toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static boolean isShowing(Context context, View view) {
    InputMethodManager imm = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE));
    return imm.isActive(view);
}

From source file:Main.java

public static void showKeyboard(Context context, View view) {
    InputMethodManager imm = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE));
    imm.showSoftInput(view, 0);/*from w w w  .  j a  v a2s. com*/
}

From source file:Main.java

public static void hideKeyboard(Activity a) {
    ((InputMethodManager) a.getSystemService(Context.INPUT_METHOD_SERVICE))
            .hideSoftInputFromWindow(a.getWindow().getDecorView().getWindowToken(), 0);
}

From source file:Main.java

public static void showSoftIput(Context context, View view) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}

From source file:Main.java

public static void closeSoftInput(Activity activity) {
    InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    im.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void dismissKeyBoard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isAcceptingText()) { // verify if the soft keyboard is open
        imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }/*  w  ww . j  a v a  2 s . c o m*/
}

From source file:Main.java

public static void showKeyboard(Activity a) {
    ((InputMethodManager) a.getSystemService(Context.INPUT_METHOD_SERVICE))
            .toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

From source file:Main.java

public static void hiddenKeybroad(View v, Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null && activity.getWindow().getCurrentFocus() != null) {
        imm.hideSoftInputFromWindow(activity.getWindow().getCurrentFocus().getWindowToken(), 0);
    }// w  w  w .j  a v  a2 s.c o m

}