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:com.androzic.track.TrackProperties.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_save:
        try {//  ww w.  ja v a 2s.  c o m
            track.name = name.getText().toString();
            track.show = show.isChecked();
            track.color = color.getColor();
            String w = (String) width.getItemAtPosition(width.getSelectedItemPosition());
            track.width = Integer.valueOf(w.trim());

            final Androzic application = Androzic.getApplication();
            application.dispatchTrackPropertiesChanged(track);

            // Hide keyboard
            final InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
            // "Close" fragment
            getFragmentManager().popBackStack();
        } catch (Exception e) {
            Log.e("TrackProperties", "Track save error", e);
            Toast.makeText(getActivity(), "Error saving track", Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.lugia.timetable.LoginActivity.java

public void onClick(View v) {
    // not continue button? i really not sure what you have clicked.
    if (v.getId() != R.id.button_continue)
        return;/*from   w w  w .java 2s.co m*/

    String mmuid = mMmuIdInput.getText().toString();
    String password = mPasswordInput.getText().toString();

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

    mProgressDialog = ProgressDialog.show(LoginActivity.this, "", "Please wait...", true, false);
    mProgressDialog.setCancelable(false);

    LoginThread thread = new LoginThread(mmuid, password);
    thread.start();
}

From source file:calibrationapp.spectoccular.com.keyboardtolinux.MainActivity.java

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

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:cl.ipp.katbag.MainActivity.java

public void hideSoftKeyboard() {
    if (getCurrentFocus() != null) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }/*from ww  w.  j  a va 2  s .c om*/
}

From source file:com.android.jhansi.designchallenge.NavigationDrawerActivity.java

protected void hideKeypad(View view) {
    View viewKeyBoard = this.getCurrentFocus();
    if (viewKeyBoard != null) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/*from  www  .  j a  va 2s.c  om*/
}

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

private void nextStep() {
    String name = edtName.getText().toString();
    String car_type = edtCar_type.getText().toString();
    String init_date = edtInit_date.getText().toString();

    /*/*  ww  w  . j  a va2s . c o m*/
    if (name.equals("")){
       this.showMessage("??", null);
       return;
    }
    if (car_type.equals("") ){
       this.showMessage("", null);
       return;
    }
    if (init_date.equals("")){
       this.showMessage("?", null);
       return;
    }
    */
    String url = String.format("api/wizardstep3?userid=%d&name=%s&type=%s&init_date=%s", AppSettings.userid,
            name, car_type, init_date);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtName.getWindowToken(), 0);
    this.get(url, 1);

}

From source file:com.tilusnet.wayta.MainActivity2.java

private void launchClavin() {
    // Retrieve the city data from the web service
    // In a worker thread since it's a network operation.

    map.clear();/*from  w  w w .  ja v a  2s .  co  m*/
    markers.clear();

    // Hide soft keyboard
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

    Toast.makeText(getApplicationContext(), "Querying...", Toast.LENGTH_SHORT).show();
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                queryClavin();
            } catch (IOException e) {
                errMsg = "Cannot retrieve cities";
                Log.e(LOG_TAG, errMsg, e);
                //               Toast.makeText(instance, errMsg, Toast.LENGTH_SHORT).show();
                return;
            }
        }
    }).start();
}

From source file:org.kepennar.android.client.social.twitter.TwitterTweetActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.twitter_tweet_activity_layout);

    _twitterApi = getApplicationContext().getConnectionRepository().findPrimaryConnectionToApi(TwitterApi.class)
            .getApi();/*from  w  w w . j  a va2 s  .co  m*/

    // Initiate the POST request when the button is clicked
    final Button button = (Button) findViewById(R.id.button_tweet);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // hide the soft keypad
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            EditText editText = (EditText) findViewById(R.id.edit_text_tweet);
            inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);

            // start asynchronous twitter post 
            new PostTweetTask().execute();
        }
    });
}

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

/**
 * Hides the soft keyboard/* w w  w.j  av a 2 s. c  om*/
 */
protected void hideSoftKeyboard() {
    if (getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }
}