Example usage for android.view.inputmethod InputMethodManager hideSoftInputFromWindow

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

Introduction

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

Prototype

public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) 

Source Link

Document

Synonym for #hideSoftInputFromWindow(IBinder,int,ResultReceiver) without a result: request to hide the soft input window from the context of the window that is currently accepting input.

Usage

From source file:Main.java

public static void hideSoftInput(Dialog dialog) {
    View view = dialog.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) dialog.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/*  ww w  . j a v  a  2s  .co  m*/
}

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);
    }/*from  w w w. j  a v  a2 s  .c  om*/
}

From source file:Main.java

public static void closeKeyboard(Dialog dialog) {
    View view = dialog.getWindow().peekDecorView();
    if (view != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from w w w.j  ava2 s .  c o m
}

From source file:Main.java

public static void hideKeyboard(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from   w w w  .  j a  v  a 2s  .  co m
}

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;//w w w  .j a v a  2  s  .  co m
    }

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

From source file:Main.java

/**
 * To hide system's keyboard./* w w w. j a  v a  2s. co m*/
 */
public static void hideSoftInput(Context appContext, View... views) {
    InputMethodManager inputManager = (InputMethodManager) appContext
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    for (View view : views) {
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}

From source file:Main.java

public static void closeInputMethod(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    if (imm != null) {
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
        }//from   ww  w . j a  v  a2 s.co m
    }
}

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);
    }/*  ww w.  ja va2 s.  c o m*/
    return false;
}

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 w w .j  av a  2s .c om
}

From source file:Main.java

public static void hideInput(Activity context) {
    InputMethodManager mInputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mInputMethodManager.isActive())
        mInputMethodManager.hideSoftInputFromWindow(context.getCurrentFocus().getWindowToken(), 0);
}