Code example for InputMethodService

Methods: getWindow

1
        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) {
            return; 
        } 
        final InputMethodManager imm = mRichImm.getInputMethodManager();
        new AsyncTask<Void, Void, Void>() {
            @Override 
            protected Void doInBackground(Void... params) {
                imm.setInputMethodAndSubtype(token, imiId, subtype);
                return null; 
            } 
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } 
 
    public boolean isShortcutImeEnabled() { 
        if (mShortcutInputMethodInfo == null) {