Example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

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

Introduction

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

Prototype

int HIDE_NOT_ALWAYS

To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestShowSelf(int) to indicate that the soft input window should normally be hidden, unless it was originally shown with #SHOW_FORCED .

Usage

From source file:edu.cmu.cylab.starslinger.view.MessagesFragment.java

public void updateKeypad() {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mRecip == null) {
        // if soft input open, close it...
        View focus = getActivity().getCurrentFocus();
        if (focus != null) {
            imm.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }/* w w w .  j  a  v  a  2  s . c om*/
    } else {
        // if soft input open, gain the focus...
        if (imm.isActive() && mEditTextMessage != null) {
            mEditTextMessage.requestFocus();
        }
    }
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (event.getUnicodeChar() != 0) {
        if (!searchView.hasFocus()) {
            setSearchText("" + (char) event.getUnicodeChar(), true);
            searchView.requestFocus();//from   ww  w . java2s.  c o  m
        }
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // Log.d(LOG, "Clearing dictionary prefs.");
        // Pretend that we just autolaunched so that we won't do it again.
        // DictionaryManagerActivity.lastAutoLaunchMillis =
        // System.currentTimeMillis();
    }
    if (keyCode == KeyEvent.KEYCODE_ENTER) {
        Log.d(LOG, "Trying to hide soft keyboard.");
        final InputMethodManager inputManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        View focus = getCurrentFocus();
        if (focus != null) {
            inputManager.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.xxjwd.chat.ChatActivity.java

 /**
 * ??//from  w w  w . j  av a  2 s.com
 */
private void hideKeyboard() {
   if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
      if (getCurrentFocus() != null)
         manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
   }
}

From source file:com.gelakinetic.mtgfam.FamiliarActivity.java

/**
 * This function hides the soft keyboard if it is being displayed. It's nice for switching fragments
 *//*ww w. ja  va  2  s .  c  o  m*/
public void hideKeyboard() {
    try {
        InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        assert getCurrentFocus() != null;
        inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (NullPointerException e) {
        /* eat it */
    }
}

From source file:com.movie.ui.message.ChatActivity.java

/**
 * ??//from ww  w  . j  a va  2  s.c  o  m
 */
@Override
protected void hideKeyboard() {
    if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getCurrentFocus() != null)
            manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:cn.kangeqiu.kq.activity.ChatActivity.java

/**
 * ??/*from  ww w  .  ja va2  s. co  m*/
 */
private void hideKeyboard() {
    if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getCurrentFocus() != null)
            manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:org.de.jmg.learn._MainActivity.java

private void hideKeyboard() {
    // Check if no view has focus:
    View view = _main.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputManager = (InputMethodManager) _main
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from   ww  w . j a va2  s.  c  o  m*/
}

From source file:com.efithealth.app.activity.ChatActivity.java

/**
 * ??/*w  w  w . j av  a  2  s .  co m*/
 */
private void hideKeyboard() {
    if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getCurrentFocus() != null)
            panel_root.setVisibility(View.GONE);
        manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:com.xuejian.client.lxp.module.toolbox.im.ChatActivity.java

/**
 * ??/*w  w w. j  a va  2  s .  c om*/
 */
private void hideKeyboard() {
    if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getCurrentFocus() != null) {
            manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}

From source file:com.openatk.field_work.MainActivity.java

private void closeKeyboard() {
    InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    //check if no view has focus:
    View v = this.getCurrentFocus();
    if (v != null) {
        inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//from   w w w . j av a2 s  . c  o  m
}