Example usage for android.content Context INPUT_METHOD_SERVICE

List of usage examples for android.content Context INPUT_METHOD_SERVICE

Introduction

In this page you can find the example usage for android.content Context INPUT_METHOD_SERVICE.

Prototype

String INPUT_METHOD_SERVICE

To view the source code for android.content Context INPUT_METHOD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.inputmethod.InputMethodManager for accessing input methods.

Usage

From source file:com.android.idearse.Login.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);//from www.ja  v  a  2s  .  c  o  m

    getWindow().getAttributes().windowAnimations = R.style.Fade;

    preferences = PreferenceManager.getDefaultSharedPreferences(this);

    loadima = (ImageView) findViewById(R.id.loading);
    rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.drawable.rotate_loading);
    rotation.setRepeatCount(Animation.INFINITE);

    ActionBar actionBar = getSupportActionBar();

    setTitle("");
    getSupportActionBar().setIcon(R.drawable.title_logo);

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);

    username = (EditText) findViewById(R.id.username);
    password = (EditText) findViewById(R.id.password);

    preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String user = preferences.getString("user", "");
    String pass = preferences.getString("password", "");

    username.setText(user);
    password.setText(pass);

    error_msg = (TextView) findViewById(R.id.error_msg);
    Button login = (Button) findViewById(R.id.login_btn);

    final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbtn);

    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("user", "");
                editor.putString("password", "");
                editor.commit();
                username.setText("");
                password.setText("");
            }
        }
    });

    if (user.length() != 0 && pass.length() != 0) {
        checkBox.setChecked(true);
    }

    login.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            if (username.length() == 0 || password.length() == 0) {
                error_msg.setText("Completa los campos");
                error_msg.setVisibility(View.VISIBLE);
            } else {
                if (checkBox.isChecked()) {
                    SharedPreferences.Editor editor = preferences.edit();
                    editor.putString("user", username.getText().toString());
                    editor.putString("password", password.getText().toString());
                    editor.commit();
                }
                error_msg.setVisibility(View.GONE);
                loadima.startAnimation(rotation);
                loadima.setVisibility(View.VISIBLE);
                new LoginQuery().execute(getString(R.string.URL) + "conectar_mobil/user/login");
            }
        }
    });
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onPause()/*w w w  . ja  v  a  2  s  . c om*/
 */
@Override
protected void onPause() {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mgr.isActive(getListView())) {
        mgr.hideSoftInputFromWindow(getListView().getWindowToken(), 0);
    }
    super.onPause();
}

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();

    /*//from  w  ww  .  j ava 2  s .  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.netpace.expressit.activity.UploadImageStoryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        if (!isGalleryPhoto) {
            this.onBackPressed();
        } else {/*from   w w w .  j  a va 2  s .  c o m*/
            Intent intent = new Intent(UploadImageStoryActivity.this, MediaOptionsActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
        return true;

    case R.id.menu_item_img_gallery:
        if (isValidate()) {
            // close the keyboard.
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0);

            getMediaKeyFromRemoteServer();
        }
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.cianmcgovern.android.ShopAndShare.Share.java

@Override
public void onCreate(Bundle savedInstanceState) {

    mContext = this;
    super.onCreate(savedInstanceState);

    setContentView(R.layout.share);/*  w  ww.jav a 2s.co  m*/

    Button upload = (Button) findViewById(R.id.uploadButton);
    upload.setText(R.string.upload);
    upload.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String userLoc = mLocationEdit.getText().toString();
            String userStore = mStore.getText().toString();
            // Don't allow empty text fields
            if (userLoc.length() > 1 && userStore.length() > 1) {
                runUpload(Results.getInstance(), userLoc, userStore);
            } else
                new AlertDialog.Builder(mContext).setTitle(R.string.invalidInput)
                        .setMessage(R.string.invalidFields).show();
        }

    });

    Button cancel = (Button) findViewById(R.id.cancelShareButton);
    cancel.setText(R.string.cancelButton);
    cancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mLocationListener != null)
                mLocationManager.removeUpdates(mLocationListener);
            finish();
        }

    });

    mLocationEdit = (EditText) findViewById(R.id.enterLocation);
    mLocationEdit.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                in.hideSoftInputFromWindow(mLocationEdit.getApplicationWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
                return true;
            }
            return false;
        }

    });
    mStore = (EditText) findViewById(R.id.enterStore);
    mStore.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                in.hideSoftInputFromWindow(mStore.getApplicationWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
                return true;
            }
            return false;
        }

    });

    mSearch = (Button) findViewById(R.id.locationButton);
    mSearch.setBackgroundResource(R.drawable.search);
    mSearch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
            if (!CheckFeatures.haveGPS()) {
                new AlertDialog.Builder(mContext).setTitle("GPS Required")
                        .setMessage("You must have GPS to use this feature").show();
            }
            // Only use GPS if it is enabled
            else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                mSearch.setEnabled(false);
                mSearch.setBackgroundResource(R.drawable.world);
                getLocation();
            } else {
                mGpsDialog = new AlertDialog.Builder(mContext).create();
                mGpsDialog.setTitle(R.string.gpsDisabled);
                mGpsDialog.setMessage(mContext.getText(R.string.gpsDisabledMessage));
                mGpsDialog.show();
            }
        }

    });
}

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;//  w ww.j  a  v a 2s  . c o m
    }
    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.prad.yahooweather.YahooWeatherActivity.java

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

From source file:name.setup.dance.DanceStepApp.java

/** Called when the activity is first created. */
@Override/*from  ww  w. j a  v a 2s. c  om*/
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "[ACTIVITY] onCreate");
    super.onCreate(savedInstanceState);

    //mStepValue = 0;
    mPaceValue = 0;

    setContentView(R.layout.main);

    mUtils = Utils.getInstance();

    String m_szDevIDShort = "35" + //we make this look like a valid IMEI
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
            + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
            + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
            + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
            + Build.USER.length() % 10; //13 digits

    mUtils.DeviceName = m_szDevIDShort;

    Log.v(TAG, "ID: " + m_szDevIDShort);
    Log.v(TAG, "UTILS: " + mUtils.DeviceName);

    // user name
    mTextField = (EditText) findViewById(R.id.name_area);
    mTextField.setCursorVisible(false);

    if (!(mUtils.UserName == "My Name")) {

        mTextField.setText(mUtils.UserName);
    }
    mTextField.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            // only will trigger it if no physical keyboard is open
            mgr.showSoftInput(mTextField, InputMethodManager.SHOW_IMPLICIT);

            mTextField.requestFocus();
            mTextField.setCursorVisible(true);
            mOkayButton.setVisibility(View.VISIBLE);

        }

    });

    // init okay Button
    mOkayButton = (Button) findViewById(R.id.okay_button);
    mOkayButton.setVisibility(View.INVISIBLE);
    mOkayButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);

            mTextField.setCursorVisible(false);
            mTextField.clearFocus();
            mUtils.UserName = mTextField.getText().toString();

            // post name via HHTP
            new Thread(new Runnable() {
                public void run() {
                    if (mIsMetric) {
                        postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue);
                    } else {
                        postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue * 1.609344f);
                    }
                }
            }).start();
            mOkayButton.setVisibility(View.INVISIBLE);

            // Post TOAST MESSAGE
            Toast.makeText(getApplicationContext(), getText(R.string.name_saved), Toast.LENGTH_SHORT).show();

        }

    });

    // init Score Button
    mScoreButton = (Button) findViewById(R.id.scoreButton);
    mScoreButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            String url = "http://www.setup.nl/tools/dancestep_app/index.php?id=" + mUtils.DeviceName + "&time="
                    + System.currentTimeMillis();
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });

}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = getApplicationContext();/*from  ww w .  j  a va2 s.  c  o m*/

    checkUpdate();

    Request.client.setUserAgent("Dodo Shoutboxapp");

    myCookieStore = new PersistentCookieStore(this);
    Request.client.setCookieStore(myCookieStore);

    Usernamefield = (TextView) findViewById(R.id.txtUsername);
    Sendbutton = (Button) findViewById(R.id.cmdSend);
    Refreshbutton = (Button) findViewById(R.id.cmdRefresh);
    pbReadChat = (ProgressBar) findViewById(R.id.pbReadChat);
    lblVerlauf = (TextView) findViewById(R.id.lblVerlauf);
    lblAutoRefresh = (TextView) findViewById(R.id.lblAutorefresh);

    if (UserData.readPref("textsize", this).equals("")) {
        UserData.writePref("textsize", "10", this);
    }
    if (UserData.readPref("refreshcircle", this).equals("")) {
        UserData.writePref("refreshcircle", "1", this);
        refreshanimation = 1;
    } else if (UserData.readPref("refreshcircle", this).equals("1")) {
        refreshanimation = 1;
    }
    /*
     * if(UserData.readPref("changechatdirection", this).equals("")) {
     * UserData.writePref("changechatdirection", "0", this); } else
     * if(UserData.readPref("changechatdirection", this).equals("1")) {
     * changechatdirection = 1; }
     */
    if (UserData.readPref("showtime", this).equals("")) {
        UserData.writePref("showtime", "1", this);
    } else {
        showTime = Integer.valueOf(UserData.readPref("showtime", this));
    }

    if (!UserData.readPref("username", this).equals("")) {
        Usernamefield.setText(UserData.readPref("username", this));
    }

    if (!UserData.readPref("autorefresh", this).equals("")) {
        Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh);
        TextView lblARefresh = (TextView) findViewById(R.id.lblAutorefresh);

        cmdRefresh.setVisibility(Button.INVISIBLE);
        lblARefresh.setVisibility(TextView.VISIBLE);
        Toast.makeText(this, "Automatisches Laden aktiviert!", Toast.LENGTH_SHORT).show();
        autorefresh = 1;
    }

    if (UserData.readPref("ar_intervall", this).equals("")) {
        UserData.writePref("ar_intervall", "30000", this);
    }

    setTextSize();
    setCookies();

    final Button cmdSend = (Button) findViewById(R.id.cmdSend);
    if (requireLogin == 1 && loggedIn == 0) {
        cmdSend.setEnabled(false);
        cmdSend.setText("Zuerst einloggen!");
    }
    cmdSend.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            send();
        }
    });

    final Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh);
    cmdRefresh.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            getRequest(baseUrl + "index.php?page=ShoutboxEntryXMLList");
        }
    });

    final Button cmdMenu = (Button) findViewById(R.id.cmdMenu);
    cmdMenu.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            // openOptionsMenu();
            Intent myIntent2 = new Intent(getApplicationContext(), Settings2.class);
            startActivityForResult(myIntent2, 0);
        }
    });

    TextView lblVerlauf = (TextView) findViewById(R.id.lblVerlauf);
    lblVerlauf.setMovementMethod(LinkMovementMethod.getInstance());
    lblVerlauf.setMovementMethod(new ScrollingMovementMethod());

}

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);
}