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:com.team3.classical.activities.SampleActivityBase.java

public void closeKeyboard() {
    // Check if no view has focus:
    View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputManager = (InputMethodManager) this
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }//from w ww .  jav a  2s .c  om

}

From source file:com.example.android.QuienLoEscribio.MainActivity.java

public void searchBooks(View view) {
    String queryString = mBookInput.getText().toString();

    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);

    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected() && queryString.length() != 0) {
        mAuthorText.setText("");
        mTitleText.setText(R.string.loading);
        Bundle queryBundle = new Bundle();
        queryBundle.putString("queryString", queryString);
        getSupportLoaderManager().restartLoader(0, queryBundle, this);
    } else {/*from  w w  w.  j  a  v  a  2 s.  co m*/
        if (queryString.length() == 0) {
            mAuthorText.setText("");
            mTitleText.setText(R.string.no_search_term);
        } else {
            mAuthorText.setText("");
            mTitleText.setText(R.string.no_network);
        }
    }
}

From source file:cn.xcom.helper.chat.easeui.ui.EaseBaseActivity.java

protected void hideSoftKeyboard() {
    if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getCurrentFocus() != null)
            inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }//  ww  w . j  av a 2s.co  m
}

From source file:com.perm.DoomPlay.SearchVkActivity.java

private void hideKeyboard() {
    InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:at.alladin.rmbt.android.util.RMBTAlertDialogFragment.java

@Override
public void onDismiss(final DialogInterface dialog) {
    //         close keyboard if open
    try {/*  www.ja va  2s  . co m*/
        final InputMethodManager imm = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception e) {
    }

    if (popBackStackIncluding != null)
        getActivity().getFragmentManager().popBackStack(popBackStackIncluding,
                FragmentManager.POP_BACK_STACK_INCLUSIVE);

    super.onDismiss(dialog);
}

From source file:de.stadtrallye.rallyesoft.fragments.AssistantAuthFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.assistant_auth_fragment, container, false);
    edit_name = (EditText) v.findViewById(R.id.name);
    edit_pass = (EditText) v.findViewById(R.id.pass);
    btn_next = (Button) v.findViewById(R.id.next);

    btn_next.setOnClickListener(new View.OnClickListener() {
        @Override//w  w  w  .ja  v  a  2s  .  c o m
        public void onClick(View v) {
            View focus = getActivity().getCurrentFocus();
            if (focus != null) {
                InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(focus.getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
            }
            onNext();
        }
    });

    edit_pass.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                onNext();
            }
            return false;
        }
    });
    return v;
}

From source file:library.artaris.cn.library.utils.SystemUtils.java

/**
 * ??/*from ww  w  . j a  va  2 s  .  c  o  m*/
 * @param activity
 */
public static void hideKeyBoard(Activity activity) {
    ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
            activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:com.example.android.whowroteit.MainActivity.java

/**
 * Gets called when the user pushes the "Search Books" button
 *
 * @param view The view (Button) that was clicked.
 *//* ww  w. j  av  a  2 s.  c  om*/
public void searchBooks(View view) {
    // Get the search string from the input field.
    String queryString = mBookInput.getText().toString();

    // Hide the keyboard when the button is pushed.
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);

    // Check the status of the network connection.
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    // If the network is active and the search field is not empty,
    // add the search term to the arguments Bundle and start the loader.
    if (networkInfo != null && networkInfo.isConnected() && queryString.length() != 0) {
        mAuthorText.setText("");
        mTitleText.setText(R.string.loading);
        Bundle queryBundle = new Bundle();
        queryBundle.putString("queryString", queryString);
        getSupportLoaderManager().restartLoader(0, queryBundle, this);
    }
    // Otherwise update the TextView to tell the user there is no connection or no search term.
    else {
        if (queryString.length() == 0) {
            mAuthorText.setText("");
            mTitleText.setText(R.string.no_search_term);
        } else {
            mAuthorText.setText("");
            mTitleText.setText(R.string.no_network);
        }
    }
}

From source file:co.dilaver.quoter.fragments.WriteYourOwnFragment.java

@Override
public void wyoSaveClicked() {
    if (!quoteText.getText().toString().equals("") && !quoteAuthor.getText().toString().equals("")) {
        SharedPrefStorage sharedPrefStorage = new SharedPrefStorage(getActivity());
        Gson gson = new Gson();

        Quote myQuote = new Quote(quoteText.getText().toString(), quoteAuthor.getText().toString());
        if (!MyApplication.savedQuotesList.contains(myQuote)) {
            MyApplication.savedQuotesList.add(myQuote);
            sharedPrefStorage.setSavedQuotes(gson.toJson(MyApplication.savedQuotesList));
        }//from   w  w  w  .  j av  a 2 s  . co  m

        InputMethodManager inputManager = (InputMethodManager) getActivity()
                .getSystemService(getActivity().INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);

        Snackbar.make(rootLayout, getString(R.string.str_AddedToFavoriteQuotes), Snackbar.LENGTH_SHORT).show();
    }
}

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();/*from  w  w w  .  ja  v  a 2  s .co  m*/

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);
    } else {
        query = intent.getStringExtra(Constants.EXTRA_QUERY_TERM);
        Log.d(TAG, "Query from other intent: " + query);
    }

    // After setting up variables so that they can be accessed in getApiUrl
    // which is called at the end of super.onCreate
    super.onCreate(savedInstanceState);

    // Push the search box into the layout group below the logo bar and above
    // the 'search results' title bar
    ViewGroup container = (ViewGroup) findViewById(R.id.TitleGroup);
    container.addView(ViewGroup.inflate(this, R.layout.partial_search_box, null), 0);
    searchBox = (EditText) findViewById(R.id.SearchText);
    searchBox.setText(query);
    searchBox.setOnKeyListener(this);
    ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button);
    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Click", "Search", 0);
            search();
        }
    });

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        inputMethodManager.hideSoftInputFromWindow(searchBox.getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}