InputConnection text committing not working

♀尐吖头ヾ 提交于 2019-12-11 14:24:57

问题


In my onCreateInputView of InputMethodService I have a BroadcastReceiver, that listens for events from my application. My BroadcastReceiver get the text and try to insert into current text field.problem is text never inserted into the current textfield everthing working fine except text not inseted in editText filed.

Here I am posting my code snippset

 @Override
    public View onCreateInputView() {
        kv = (KeyboardView) getLayoutInflater().inflate(R.layout.activity_main, null);
        keyboard = new Keyboard(this, R.xml.qwerty);
        kv.setKeyboard(keyboard);
        kv.setOnKeyboardActionListener(this);

        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String resultData = intent.getStringExtra(Main2Activity.SERVICE_MESSAGE);

                InputConnection ic = getCurrentInputConnection();
                if (ic != null) {
                    ic.commitText(resultData, resultData.length());
                }
            }
        };

        LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
        lbm.registerReceiver(broadcastReceiver, new IntentFilter(Main2Activity.SERVICE_RESULT));

        return kv;
    }

来源:https://stackoverflow.com/questions/56971234/inputconnection-text-committing-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!