1

I am committing text when user press key using the key code in InputConnection

but this method will hang the view and it will release after few milliseconds

if (getCurrentInputConnection() != null) {
    getCurrentInputConnection().commitText(String.valueOf((char) charCode), 1);
}

Is am I doing something wrong, or any other solution?

Priyanka
  • 3,369
  • 1
  • 10
  • 33

2 Answers2

0

Why not just create an instance from getCurrentInputConnection()?

String txt = String.valueOf((char) charCode);
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
    ic.commitText(txt , 1);
}
Deˣ
  • 4,191
  • 15
  • 24
0

Don't use commitText() on each keypress.

Use

getCurrentInputConnection().setComposingText(mComposingText, 1);

for all keypress and commit composing text on space press.

To commit composing text use

getCurrentInputConnection().finishComposingText();

It was solved my issue

Priyanka
  • 3,369
  • 1
  • 10
  • 33