android.view.inputmethod.InputMethodManager#isActive ( )源码实例Demo

下面列出了android.view.inputmethod.InputMethodManager#isActive ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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();
    if (inputMethodManager != null) {
        if (inputMethodManager.isActive(mYearSpinnerInput)) {
            mYearSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mMonthSpinnerInput)) {
            mMonthSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mDaySpinnerInput)) {
            mDaySpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        }
    }
}
 
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();
    if (inputMethodManager != null) {
        if (inputMethodManager.isActive(mHourSpinnerInput)) {
            mHourSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mMinuteSpinnerInput)) {
            mMinuteSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        } else if (inputMethodManager.isActive(mAmPmSpinnerInput)) {
            mAmPmSpinnerInput.clearFocus();
            inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
        }
    }
}
 
源代码3 项目: nono-android   文件: PinViewBaseHelper.java
/**
 * Keyboard back button
 */
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {

    if (mKeyboardMandatory) {
        if (getContext() != null) {
            InputMethodManager imm = (InputMethodManager) getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            if (imm.isActive() && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
                setImeVisibility(true);
                return true;
            }
        }
    }
    return super.dispatchKeyEventPreIme(event);
}
 
源代码4 项目: Tok-Android   文件: SystemUtils.java
public static void hideSoftKeyBoard(Activity activity) {
    try {
        InputMethodManager imm =
            (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null && imm.isActive() && activity.getCurrentFocus() != null) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码5 项目: Tok-Android   文件: SystemUtils.java
public static void openSoftKeyBoard(Activity activity) {
    try {
        InputMethodManager imm =
            (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive() && activity.getCurrentFocus() != null) {
            imm.showSoftInput(activity.getCurrentFocus(), 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码6 项目: nono-android   文件: InputTools.java
public static void HideKeyboard(View v)
{
    InputMethodManager imm = ( InputMethodManager ) v.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE );
    if ( imm.isActive( ) ) {
        imm.hideSoftInputFromWindow( v.getApplicationWindowToken( ) , 0 );

    }
}
 
源代码7 项目: android_9.0.0_r45   文件: NumberPicker.java
/**
 * Hides the soft input if it is active for the input text.
 */
private void hideSoftInput() {
    InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
    if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
        inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
    }
    if (mHasSelectorWheel) {
        mInputText.setVisibility(View.INVISIBLE);
    }
}
 
源代码8 项目: Mover   文件: ViewUtils.java
public static void hideKeyboard(View view) {
    if (view == null) {
        return;
    }
    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (!imm.isActive()) {
        return;
    }
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
源代码9 项目: ticdesign   文件: NumberPicker.java
/**
 * Hides the soft input if it is active for the input text.
 */
private void hideSoftInput() {
    InputMethodManager inputMethodManager = getValidInputMethodManager();
    if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
        inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        if (mHasSelectorWheel) {
            mInputText.setVisibility(View.INVISIBLE);
        }
    }
}
 
源代码10 项目: SprintNBA   文件: SearchEditText.java
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    pressSearch = (keyCode == KeyEvent.KEYCODE_ENTER);
    if (pressSearch && listener != null) {
        /*隐藏软键盘*/
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
        }
        listener.onSearchClick(v);
    }
    return false;
}
 
源代码11 项目: AndroidWallet   文件: AppKeyBoardMgr.java
/**
 * 输入法是否显示
 */
public static boolean isKeybord(EditText edittext) {
    boolean bool = false;
    InputMethodManager inputMethodManager = (InputMethodManager)
        edittext.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        bool = true;
    }
    return bool;
}
 
源代码12 项目: SuperNote   文件: EditNotePresenter.java
@Override
public void closeKeyboard(View view) {
    InputMethodManager manager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (manager.isActive()) {
        manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
源代码13 项目: sealtalk-android   文件: CommonUtils.java
/**
 * 显示软键盘
 * @param activity
 */
public static void showKeyboard(Activity activity) {
	if(activity != null){
		InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
		if(!imm.isActive()){
			imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
		}
	}
}
 
源代码14 项目: Telegram   文件: AndroidUtilities.java
public static void hideKeyboard(View view) {
    if (view == null) {
        return;
    }
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            return;
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
源代码15 项目: kAndroid   文件: CommonUtils.java
/**
 * 隐藏键盘
 *
 * @param ctx
 * @param v
 * @return
 */
public static boolean hideSoftInputFromWindow(Context ctx, View v) {
    InputMethodManager imm = (InputMethodManager) ctx
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        return true;
    }
    return false;
}
 
源代码16 项目: nono-android   文件: InputTools.java
public static boolean KeyBoard(EditText edittext)
{
    boolean bool = false;
    InputMethodManager imm = ( InputMethodManager ) edittext.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE );
    if ( imm.isActive( ) )
    {
        bool = true;
    }
    return bool;

}
 
源代码17 项目: PlayTogether   文件: ScreenUtils.java
/**
 * 隐藏软键盘
 */
public static void hideKeyboard(Context context)
{
	Activity activity = (Activity) context;
	if (activity != null)
	{
		InputMethodManager imm = (InputMethodManager) activity
						.getSystemService(Context.INPUT_METHOD_SERVICE);
		if (imm.isActive() && activity.getCurrentFocus() != null)
		{
			imm.hideSoftInputFromWindow(activity.getCurrentFocus()
							.getWindowToken(), 0);
		}
	}
}
 
public void onClickClose(View view) {
    InputMethodManager input = (InputMethodManager) binding.pinEntry.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (input != null && input.isActive()) {
        input.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }
    dismiss();
}
 
源代码19 项目: KrGallery   文件: AndroidUtilities.java
public static boolean isKeyboardShowed(View view) {
    if (view == null) {
        return false;
    }
    try {
        InputMethodManager inputManager = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        return inputManager.isActive(view);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
源代码20 项目: AndroidBase   文件: InputMethodUtils.java
public static boolean isActive(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.isActive();
}