It turned out that the above use of InputConnectionWrapper was absolutely correct. However, commitText() never called (except in special cases), as there are other methods that are used in typing. This is basically setComposingText() and sendKeyEvent() .
However, it is also important to override rarely used methods such as deleteSurroundingText() or commitText() to catch every user input, because I ran into a similar problem.
My situation: I have an EditText view of user types. EditText is cleared when the user clicks a button. When I quickly press the button, a lot of inactive InputConnection entries InputConnection .
eg. editText.setText(null);
The last line in my logcat above gives an excellent idea of ββwhat is going on. Of course, InputConnection overloaded with clear-text requests. I tried changing the code to check the length of the text before trying to clear it:
if (editText.length() > 0) { editText.setText(null); }
This helps alleviate the problem, since clicking a button quickly does not trigger an IInputConnectionWrapper alert IInputConnectionWrapper . However, this is still prone to problems when the user quickly alternates between entering something and pressing a button or pressing a button, when the application is under sufficient load, etc.
Fortunately, I found another way to clear the text: Editable.clear() . With this, I don't get any warnings at all:
if (editText.length() > 0) { editText.getText().clear(); }
Note that if you want to clear all input state, not just text (autotext, autocap, multitap, undo), you can use TextKeyListener.clear(Editable e) .
if (editText.length() > 0) { TextKeyListener.clear(editText.getText()); }
If you want to know more about the input connection shell, follow the link below.
http://developer.android.com/reference/android/view/inputmethod/InputConnection.html