Example usage for android.view.inputmethod InputMethodManager hideSoftInputFromWindow

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

Introduction

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

Prototype

public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) 

Source Link

Document

Synonym for #hideSoftInputFromWindow(IBinder,int,ResultReceiver) without a result: request to hide the soft input window from the context of the window that is currently accepting input.

Usage

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

@Override
public void onDismiss(final DialogInterface dialog) {
    //         close keyboard if open
    try {/*  w  ww  . j  a  v  a  2  s .  c  o  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:com.atwal.wakeup.battery.util.Utilities.java

public static void hideSoftInput(InputMethodManager inputManager, View v) {
    if (inputManager.isActive()) {
        inputManager.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
    }// w ww .jav a 2  s.  co  m
}

From source file:cn.count.easydrive366.signup.Step2Activity.java

private void nextStep() {
    String vin = edtVIN.getText().toString();
    String engine_no = edtEngine_no.getText().toString();
    String registration_date = edtRegistration_date.getText().toString();
    String owner_name = edtOwner_name.getText().toString();
    String owner_license = edtOwner_license.getText().toString();
    /*/*from w w  w  . j a v a2 s.c  om*/
    if (vin.equals("")){
       this.showMessage("VIN?", null);
       return;
    }
    if (engine_no.equals("") ){
       this.showMessage("??", null);
       return;
    }
    if (registration_date.equals("")){
       this.showMessage("?", null);
       return;
    }
    */
    String url = String.format(
            "api/wizardstep2?userid=%d&vin=%s&engine_no=%s&registration_date=%s&owner_name=%s&owner_license=%s",
            AppSettings.userid, vin, engine_no, registration_date, owner_name, owner_license);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtVIN.getWindowToken(), 0);
    this.get(url, 1);

}

From source file:com.firesoft.member.Activity.B2_SignupActivity.java

private void CloseKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mNickname.getWindowToken(), 0);
}

From source file:cn.count.easydrive366.signup.Step1Activity.java

private void nextStep() {
    String car_no = edtCar_no.getText().toString();
    String id_no = edtId_no.getText().toString();
    String vin = edt_vin.getText().toString();
    if (car_no.equals("")) {
        this.showMessage("???", null);
        return;/*from  w  w w .  j a  v  a  2s. c om*/
    }
    if (!id_no.equals("")) {

        if (id_no.length() != 18 || !personIdValidation(id_no)) {
            this.showMessage(this.getResources().getString(R.string.id_is_wrong), null);
            return;
        }
    }

    String url = String.format("api/wizardstep1?userid=%d&car_id=%s&license_id=%s&vin=%s&phone=%s",
            AppSettings.userid, car_no.toUpperCase(), id_no, vin.toUpperCase(), edt_phone.getText().toString());
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtCar_no.getWindowToken(), 0);
    this.get(url, 1);

}

From source file:com.android.cts.uiautomator.Test1DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View rootView = inflater.inflate(R.layout.test1_detail_fragment, container, false);
    if (mItem != null) {
        ((EditText) rootView.findViewById(R.id.test1TextField)).setText(mItem.mName);

        mSubmitButton = (Button) rootView.findViewById(R.id.test1SubmitButton);
        mEditText = (EditText) rootView.findViewById(R.id.test1TextField);
        mEditText.setText("");
        mSubmitButton.setOnClickListener(new Button.OnClickListener() {
            @Override//from ww w  . j  a v  a2s.  c o  m
            public void onClick(View v) {
                final String savedInput = mEditText.getText().toString();
                // clear so we won't be confused by the input text in
                // validation
                mEditText.setText("");
                // close soft keyboard
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
                // display the submitted text
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.item1_dialog_title);
                builder.setPositiveButton(R.string.OK, null);
                builder.setMessage(savedInput);
                AlertDialog diag = builder.create();
                diag.show();
            }
        });
    }
    return rootView;
}

From source file:can.yrt.onebusaway.ReportStopProblemFragment.java

@Override
protected void sendReport() {
    // Hide the soft keyboard.
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mUserComment.getWindowToken(), 0);
    super.sendReport();
}

From source file:edu.rowan.app.fragments.FoodCommentFragment.java

public void hideKeyboard(EditText commentField) {
    // hide keyboard
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(commentField.getWindowToken(), 0);
}

From source file:com.android.example.github.ui.search.SearchFragment.java

private void dismissKeyboard(IBinder windowToken) {
    FragmentActivity activity = getActivity();
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(windowToken, 0);
    }// w w  w  .  j av a2s . c  o  m
}

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.  ja  v  a  2s.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();
    }
}