Example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Prototype

int HIDE_NOT_ALWAYS

To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestShowSelf(int) to indicate that the soft input window should normally be hidden, unless it was originally shown with #SHOW_FORCED .

Usage

From source file:Main.java

public static void hideKkeyboard(Activity activity) {
    try {//  w w  w  . ja v  a2s  .  co  m
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void closeInputMethod(View view, Context mContext) {
    InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    boolean isOpen = imm.isActive();
    if (isOpen) {
        imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//w ww  .j a  v a  2  s.  co m
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    try {//from   ww  w.java2s.  c o m
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void closeInputMethodWindow(Activity activity) {
    try {// ww w .  ja v a  2  s  .  c o m
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Throwable th) {
        th.printStackTrace();
    }
}

From source file:Main.java

public static boolean hideInputSoft(View trigger) {
    InputMethodManager inputMethodManager = (InputMethodManager) trigger.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    return inputMethodManager.hideSoftInputFromWindow(trigger.getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideSoftKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    // imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    if (imm.isActive()) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }// w ww .  j  av  a2 s  . c  o  m
}

From source file:Main.java

public static void hideSoftKeyboard(Context context, View view) {
    if (context == null || view == null) {
        return;/*from   ww  w.j av  a 2 s.c  om*/
    }

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

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 {//from w w w. ja v  a2s  .co m
        if (activity.getCurrentFocus() != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}

From source file:Main.java

public static void hideKeyboard(Context context, View view) {
    view.requestFocus();//from w  ww . j  a v a  2s  .  c  o m
    imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideSoftKeyBoard(Activity activity) {
    if (null == activity.getCurrentFocus()) {
        return;//from  w  ww .  j a v  a2  s  .c om
    }
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}