Example usage for android.view View getWindowToken

List of usage examples for android.view View getWindowToken

Introduction

In this page you can find the example usage for android.view View getWindowToken.

Prototype

public IBinder getWindowToken() 

Source Link

Document

Retrieve a unique token identifying the window this view is attached to.

Usage

From source file:Main.java

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

From source file:Main.java

public static void hideInput(Context context, View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

/**
 * Force hide soft keyboard with flag : InputMethodManager.HIDE_NOT_ALWAYS.
 * @param context Context to get system service input method.
 * @param viewBinder View has current focus. Can achived by View.getWindowToken().
 *//*w  w w.  ja  v  a 2  s  . c  om*/
public static void hideKeyboard(Context context, View viewBinder) {
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(viewBinder.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideSoftKeyboard(Context context, View inputView) {
    if (inputView == null)
        return;//w w  w. j  a  v  a 2 s .  co m

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(inputView.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Context context, View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideInput(View view) {
    try {/*  ww w.  ja va2  s.c  o m*/
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void hideKeyboard(Activity _activity, View _view) {
    InputMethodManager inputMethodManager = (InputMethodManager) _activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(_view.getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(View view, Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

public static void hide(Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/* w  ww.  jav  a  2s .  c o  m*/
}

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