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.screenspeak.eventprocessor.ProcessorPhoneticLetters.java

/**
 * Handle an event that indicates a key is held on the soft keyboard.
 *///from   w ww  . jav  a2  s. c om
private void processKeyboardKeyEvent(AccessibilityEvent event) {
    final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event);
    if (TextUtils.isEmpty(text)) {
        return;
    }

    String localeString = FALLBACK_LOCALE;
    InputMethodManager inputMethodManager = (InputMethodManager) mService
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    InputMethodSubtype inputMethod = inputMethodManager.getCurrentInputMethodSubtype();
    if (inputMethod != null) {
        localeString = inputMethod.getLocale();
    }

    String phoneticLetter = getPhoneticLetter(localeString, text.toString());
    if (phoneticLetter != null) {
        postPhoneticLetterRunnable(phoneticLetter);
    }
}

From source file:net.olejon.mdapp.MedicationActivity.java

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

    // Intent/*from w  ww  . ja v  a  2 s .  c o  m*/
    final Intent intent = getIntent();

    medicationId = intent.getLongExtra("id", 0);

    if (medicationId == 0) {
        mTools.showToast(getString(R.string.medication_could_not_find_medication), 1);

        finish();

        return;
    }

    // Input manager
    mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Layout
    setContentView(R.layout.activity_medication);

    // View
    mRelativeLayout = (RelativeLayout) findViewById(R.id.medication_inner_layout);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.medication_toolbar);
    mToolbar.setTitle("");

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mToolbarSearchLayout = (LinearLayout) findViewById(R.id.medication_toolbar_search_layout);
    mToolbarSearchEditText = (EditText) findViewById(R.id.medication_toolbar_search);

    // View pager
    mViewPager = (ViewPager) findViewById(R.id.medication_pager);

    // Find in text
    mToolbarSearchEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            String find = mToolbarSearchEditText.getText().toString().trim();

            if (find.equals("")) {
                if (mWebView != null)
                    mWebView.clearMatches();
            } else {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    if (mWebView != null)
                        mWebView.findAllAsync(find);
                } else {
                    if (mWebView != null) {
                        //noinspection deprecation
                        mWebView.findAll(find);
                    }
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    mToolbarSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_SEARCH || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0);

                return true;
            }

            return false;
        }
    });
}

From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java

private void check() {
    // ?/*from w  ww.j av a2 s .c  o m*/
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(et_code.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    String code = et_code.getText().toString().trim();
    if (TextUtils.isEmpty(code)) {
        BaseUtils.showMsg(this,
                getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_epin_notice_5")));
        return;
    }
    setWaitScreen(true);
    HttpService.instance().postEpinCode(code.toUpperCase(), new MyCallback(this));
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "OnCreate!!~~~");

    ctx = this;//from ww w.  j a  va2s  .co m
    // Setup the window
    //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Set result CANCELED incase the user backs out
    setResult(Activity.RESULT_CANCELED);

    ////////////////////////////////////////////////////////////////////

    tabHost = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.activity_admin_manage, tabHost.getTabContentView(), true);
    tabHost.addTab(tabHost.newTabSpec("Assign ID").setIndicator("Assign ID", null).setContent(R.id.tab_assign));
    tabHost.addTab(tabHost.newTabSpec("Remove ID").setIndicator("Remove ID", null).setContent(R.id.tab_logoff));

    setContentView(tabHost);

    shp = getSharedPreferences(Utilities.SP_LOGIN, Context.MODE_PRIVATE);
    editor = shp.edit();
    asID = (EditText) findViewById(R.id.assigned_ID);
    deasID = (EditText) findViewById(R.id.deassigned_ID);
    AssignButton = (Button) findViewById(R.id.btn_assign);
    RemoveButton = (Button) findViewById(R.id.btn_remove);

    imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
    //imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);

    //imm.showSoftInput(asID, InputMethodManager.RESULT_SHOWN); 
    imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, InputMethodManager.RESULT_HIDDEN);

    asID.setFocusable(true);
    asID.setFocusableInTouchMode(true);

    asID.requestFocus();

    setListeners();

    DialadminPin = AdminPinSetDialog(this);
    DialadminPin.show();

    setHints();
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "OnCreate!!~~~");

    ctx = this;/*  w  w  w  .  j  a  v  a  2 s .c  o m*/
    // Setup the window
    //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Set result CANCELED in case the user backs out
    setResult(Activity.RESULT_CANCELED);

    ////////////////////////////////////////////////////////////////////

    tabHost = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.activity_admin_manage, tabHost.getTabContentView(), true);
    tabHost.addTab(tabHost.newTabSpec("Assign ID").setIndicator("Assign ID", null).setContent(R.id.tab_assign));
    tabHost.addTab(tabHost.newTabSpec("Remove ID").setIndicator("Remove ID", null).setContent(R.id.tab_logoff));

    setContentView(tabHost);

    shp = getSharedPreferences(Util.SP_LOGIN, Context.MODE_PRIVATE);
    editor = shp.edit();
    asID = (EditText) findViewById(R.id.assigned_ID);
    deasID = (EditText) findViewById(R.id.deassigned_ID);
    AssignButton = (Button) findViewById(R.id.btn_assign);
    RemoveButton = (Button) findViewById(R.id.btn_remove);

    imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
    //imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);

    //imm.showSoftInput(asID, InputMethodManager.RESULT_SHOWN);
    imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, InputMethodManager.RESULT_HIDDEN);

    asID.setFocusable(true);
    asID.setFocusableInTouchMode(true);

    asID.requestFocus();

    setListeners();

    DialadminPin = AdminPinSetDialog(this);
    DialadminPin.show();

    setHints();
}

From source file:edu.missouri.bas.activities.AdminManageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "OnCreate!!~~~");

    ctx = this;//from   w w w  . j  a  v a 2  s  .com
    // Setup the window
    //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Set result CANCELED incase the user backs out
    //setResult(Activity.RESULT_CANCELED);

    ////////////////////////////////////////////////////////////////////

    tabHost = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.activity_admin_manage, tabHost.getTabContentView(), true);
    tabHost.addTab(tabHost.newTabSpec("Assign ID").setIndicator("Assign ID", null).setContent(R.id.tab_assign));
    tabHost.addTab(tabHost.newTabSpec("Remove ID").setIndicator("Remove ID", null).setContent(R.id.tab_logoff));

    setContentView(tabHost);

    shp = getSharedPreferences("PINLOGIN", Context.MODE_PRIVATE);
    editor = shp.edit();
    bedTime = ctx.getSharedPreferences(SensorService.BED_TIME, MODE_PRIVATE);
    editor2 = bedTime.edit();
    asID = (EditText) findViewById(R.id.assigned_ID);
    deasID = (EditText) findViewById(R.id.deassigned_ID);
    AssignButton = (Button) findViewById(R.id.btn_assign);
    RemoveButton = (Button) findViewById(R.id.btn_remove);

    imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
    //imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);

    //imm.showSoftInput(asID, InputMethodManager.RESULT_SHOWN); 
    imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, InputMethodManager.RESULT_HIDDEN);

    asID.setFocusable(true);
    asID.setFocusableInTouchMode(true);

    asID.requestFocus();

    setListeners();

    Dialog adminPin = AdminPinDialog(this);
    adminPin.show();

    setResult(9);
    setHints();
}

From source file:com.imalu.alyou.activity.FriendlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*  w  w  w. j a v  a 2s. c  o  m*/
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    relativeLayout = (RelativeLayout) getView().findViewById(R.id.add_friend_layout);
    groups = (RelativeLayout) getView().findViewById(R.id.groups);
    sidebar.setListView(listView);
    sidebar.setVisibility(ViewGroup.GONE);
    relativeLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(getActivity(), FindFriendActivity.class));
        }
    });

    groups.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(getActivity(), GroupsActivity.class));
        }
    });
    showListView();
    //      //???
    //      //blackList = EMContactManager.getInstance().getBlackListUsernames();
    //      contactList = new ArrayList<HXUser>();
    //      // ?contactlist
    //      getContactList();
    //      // adapter
    //      adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar);
    //      listView.setAdapter(adapter);
    //      listView.setOnItemClickListener(new OnItemClickListener() {
    //
    //         @Override
    //         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    //            String username = adapter.getItem(position).getUsername();
    //            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
    //               // ?
    //               HXUser user = AlUApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME);
    //               user.setUnreadMsgCount(0);
    //               startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
    //            } else if (Constant.GROUP_USERNAME.equals(username)) {
    //               // ??
    //               startActivity(new Intent(getActivity(), GroupsActivity.class));
    //            } else {
    //               // demo??
    //               startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername()));
    //            }
    //         }
    //      });
    //      listView.setOnTouchListener(new OnTouchListener() {
    //
    //         @Override
    //         public boolean onTouch(View v, MotionEvent event) {
    //            // ??
    //            if (getActivity().getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
    //               if (getActivity().getCurrentFocus() != null)
    //                  inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
    //                        InputMethodManager.HIDE_NOT_ALWAYS);
    //            }
    //            return false;
    //         }
    //      });
    //
    //      ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    //      // ?
    //      addContactView.setOnClickListener(new OnClickListener() {
    //
    //         @Override
    //         public void onClick(View v) {
    //            startActivity(new Intent(getActivity(), AddContactActivity.class));
    //         }
    //      });
    //      registerForContextMenu(listView);
    //      setView();
    //      setLisetener();

}

From source file:com.j_o.android.imdb_client.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mediaList = new ArrayList<Media>();
    mediaGrid = (GridView) findViewById(R.id.media_grid_view);
    editTxMediaSearch = (EditText) findViewById(R.id.edit_search_media);

    // Input filter that not allow special characters.
    InputFilter filter = new InputFilter() {
        @Override/*from w  ww  .j ava 2  s .c  o  m*/
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {

            if (source instanceof SpannableStringBuilder) {
                SpannableStringBuilder sourceAsSpannableBuilder = (SpannableStringBuilder) source;
                for (int i = end - 1; i >= start; i--) {
                    char currentChar = source.charAt(i);
                    if (!Character.isLetterOrDigit(currentChar) && !Character.isSpaceChar(currentChar)) {
                        sourceAsSpannableBuilder.delete(i, i + 1);
                    }
                }
                return source;
            } else {
                StringBuilder filteredStringBuilder = new StringBuilder();
                for (int i = 0; i < end; i++) {
                    char currentChar = source.charAt(i);
                    if (Character.isLetterOrDigit(currentChar) || Character.isSpaceChar(currentChar)) {
                        filteredStringBuilder.append(currentChar);
                    }
                }
                return filteredStringBuilder.toString();
            }
        }
    };
    editTxMediaSearch.setFilters(new InputFilter[] { filter });

    editTxMediaSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                new AskForMediaAsyncTaks().execute(editTxMediaSearch.getText().toString());
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(editTxMediaSearch.getWindowToken(), 0);
                return true;
            }
            return false;
        }

    });

}

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 .ja v  a2  s. c  o  m
    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:edu.rit.csh.androidwebnews.RecentActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getSupportMenuInflater().inflate(R.menu.displaythreads_menu, menu);
    // Get the SearchView and set the searchable configuration
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            return true;
        }//w  w  w  .  j  a v a 2 s.  c o  m

        public boolean onQueryTextSubmit(String query) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            //    imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
            Intent intent = new Intent(RecentActivity.this, SearchResultsActivity.class);
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("keywords", query);
            intent.putExtra("params", params);
            startActivity(intent);
            return true;
        }
    };
    searchView.setOnQueryTextListener(queryTextListener);
    return super.onCreateOptionsMenu(menu);
}