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(View view) 

Source Link

Document

Return true if the given view is the currently active view for the input method.

Usage

From source file:Main.java

public static boolean isActive(Context context, View focusView) {
    InputMethodManager imm = from(context);
    return imm.isActive(focusView);
}

From source file:Main.java

public static boolean isShowing(Context context, View view) {
    InputMethodManager imm = ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE));
    return imm.isActive(view);
}

From source file:Main.java

public static void showSoftKeyBoard(Activity activity, View view) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (!imm.isActive(view)) {
        imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }//from w  ww.ja va2  s  .c o  m

}

From source file:Main.java

public static boolean isKeyboardShowed(View view) {
    if (view == null) {
        return false;
    }//ww  w.  j  av a 2  s.co m
    InputMethodManager inputManager = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    return inputManager.isActive(view);
}

From source file:Main.java

public static boolean isKeyboardShowed(View view) {
    if (view == null) {
        return false;
    }//from   w w  w  . j a v a2  s  .co  m
    try {
        InputMethodManager inputManager = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        return inputManager.isActive(view);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onPause()//from   w  w  w  . ja v a 2 s .c  o m
 */
@Override
protected void onPause() {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mgr.isActive(getListView())) {
        mgr.hideSoftInputFromWindow(getListView().getWindowToken(), 0);
    }
    super.onPause();
}

From source file:com.android.printspooler.widget.PrintContentView.java

private void ensureImeClosedAndInputFocusCleared() {
    View focused = findFocus();//www. j  a  v a2s . co m

    if (focused != null && focused.isFocused()) {
        InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive(focused)) {
            imm.hideSoftInputFromWindow(getWindowToken(), 0);
        }
        focused.clearFocus();
    }
}

From source file:com.radicaldynamic.groupinform.application.Collect.java

/**
 * Creates and displays a dialog displaying the violated constraint.
 *//*from w  w w.  j  a  v  a2  s.c o  m*/
public void showSoftKeyboard(View v) {
    InputMethodManager inputManager = (InputMethodManager) getBaseContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    IBinder b = v.getWindowToken();
    if (viewToken != null && !viewToken.equals(b)) {
        inputManager.hideSoftInputFromInputMethod(viewToken, 0);
    }

    if (inputManager.isActive(v))
        return;
    inputManager.showSoftInput(v, 0);
    viewToken = b;
}

From source file:kr.wdream.storyshop.AndroidUtilities.java

public static boolean isKeyboardShowed(View view) {
    if (view == null) {
        return false;
    }/*from  w  ww  . ja  v  a  2  s . co m*/
    try {
        InputMethodManager inputManager = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        return inputManager.isActive(view);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return false;
}

From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java

private void updateInputState() {
    // Make sure that if the user changes the value and the IME is active
    // for one of the inputs if this widget, the IME is closed. If the user
    // changed the value via the IME and there is a next input the IME will
    // be shown, otherwise the user chose another means of changing the
    // value and having the IME up makes no sense.
    //InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
    InputMethodManager inputMethodManager = (InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        if (inputMethodManager.isActive(mHourSpinnerInput)) {
            mHourSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mMinuteSpinnerInput)) {
            mMinuteSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mAmPmSpinnerInput)) {
            mAmPmSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        }//from  w ww .  j  ava 2  s  .  c  o  m
    }
}