Code example for InputMethodService

Methods: getWindow

        switchToTargetIME(imiId, mShortcutSubtype, context);
    private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
            final InputMethodService context) {
        final IBinder token = context.getWindow().getWindow().getAttributes().token;
        if (token == null) {
        final InputMethodManager imm = mRichImm.getInputMethodManager();
        new AsyncTask<Void, Void, Void>() {
            protected Void doInBackground(Void... params) {
                imm.setInputMethodAndSubtype(token, imiId, subtype);
                return null; 
    public boolean isShortcutImeEnabled() { 
Connect your IDE to all the code out there  Get Codota for Java