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 hideKeys(Context context, TextView textView) {
    textView.setCursorVisible(false);/*from  w w  w . ja  v  a 2 s.co  m*/

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

From source file:Main.java

public static void hide(final Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from   www. j  a v a  2 s .c  om
}

From source file:Main.java

/**
 * Hides the SoftKeyboard input careful as if you pass a view that didn't open the
 * soft-keyboard it will ignore this call and not close
 *
 * @param context the context / usually the activity that the view is being shown within
 * @param v       the view that opened the soft-keyboard
 *///www.j  av  a  2s.c om
public static void requestHideKeyboard(Context context, View v) {
    InputMethodManager imm = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE));
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

From source file:Main.java

public static void hideSoftInput(Activity activity) {
    try {/*w w w.j  ava  2s  . c o  m*/
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void hideInputMethod(Context context, IBinder windowToken) {
    try {/*from w w  w.j  ava2 s  .  c o  m*/
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(windowToken, 0);
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void hideKeyboard(Context context) {

    View view = ((Activity) context).getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/*from   ww  w  .  j  av  a  2 s  .co m*/
}

From source file:Main.java

public static void hideSoftKeyboard(Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from  w  ww.  j a  v a2  s  . com
}

From source file:Main.java

public static void hideKeyboard(Context context, View view) {
    if (context == null) {
        throw new IllegalArgumentException("context cannot be null");
    }//from  www  .  j  a  v a2 s  .c  om
    if (view == null) {
        throw new IllegalArgumentException("view cannot be null");
    }
    InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hiddenSoftKeyBoard(Context context) {
    try {/*from  w  w w. j a va  2 s . com*/
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getApplicationWindowToken(), 0);
    } catch (Exception e) {

    }
}

From source file:Main.java

public static void hideInputSoftFromWindowMethod(Context context, View view) {
    try {// w  w  w .j av  a  2 s .c o m
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}