Example usage for android.view.inputmethod InputMethodManager isActive

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

Introduction

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

Prototype

public boolean isActive() 

Source Link

Document

Return true if any view is currently active in the input method.

Usage

From source file:Main.java

/**
 * get the SoftInput state//from www .  j ava 2  s  .  c  o  m
 * 
 * @param activity
 * @return if shown return true else return false
 */
public static boolean softInputIsShow(Activity activity) {
    if (activity == null) {
        return false;
    }
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.isActive();
}

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  w w.j a  v a  2 s .com*/
}

From source file:Main.java

public static void toggleKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }// ww w  . ja v  a2 s.  com
}

From source file:Main.java

public static void hiddenKeyBoard(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive())
        imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
}

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);
}

From source file:Main.java

public static boolean KeyBoard(EditText edittext) {
    InputMethodManager imm = (InputMethodManager) edittext.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.isActive();
}

From source file:Main.java

public static void showKeyboard(View view) {
    if (view == null) {
        return;/*w w  w .j a  v  a2  s.  co  m*/
    }
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (!imm.isActive()) {
        return;
    }
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

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);
        }/* www. jav a 2 s  .  c  o  m*/
    }
}

From source file:Main.java

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

From source file:Main.java

public static void toggleKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from ww w .j  ava  2  s  . c o m*/
}