InputConnectionWrapper Warning

I get an InputConnectionWrapper warning every time I turn off the screen when my application is visible. I do not know why, because I do not use InputConnection .

Here is the output of LogCat.

 09-07 14:21:31.716: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:31.724: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): beginBatchEdit on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): endBatchEdit on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): beginBatchEdit on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): endBatchEdit on inactive InputConnection 09-07 14:21:31.732: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:32.013: W/IInputConnectionWrapper(24197): showStatusIcon on inactive InputConnection 09-07 14:21:32.013: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): beginBatchEdit on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): endBatchEdit on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextBeforeCursor on inactive InputConnection 09-07 14:21:32.021: W/IInputConnectionWrapper(24197): getTextAfterCursor on inactive InputConnection 09-07 14:21:32.028: W/IInputConnectionWrapper(24197): beginBatchEdit on inactive InputConnection 09-07 14:21:32.028: W/IInputConnectionWrapper(24197): endBatchEdit on inactive InputConnection 09-07 14:21:32.028: W/IInputConnectionWrapper(24197): getExtractedText on inactive InputConnection 
+9
android warnings
source share
4 answers

Guessing is too late to help, but in my case the problem is that I have a " setOnEditorActionListener " when editing text. If I remove this listener, the warning disappears.

0
source share

In my case, in the button layout, I had this: android:textIsSelectable="true" , just deleting it and the problem was solved ...

0
source share
 TextWatcher textWatcherContent = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String content = mTxtContent.getText().toString(); String contact = mTxtContact.getText().toString(); if (null != mTxtContent && null != mTxtLength) { int length = mTxtContent.getText().toString().length(); if (length > 200) { mTxtContent.removeTextChangedListener(textWatcherContent); SpannableString spannableString = new SpannableString(content); spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF3838")), 200 , mTxtContent.length() , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mTxtContent.getText().clear(); mTxtContent.append(spannableString); mTxtContent.setSelection(content.length()); mTxtContent.addTextChangedListener(textWatcherContent); } } } }; 
0
source share

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

-4
source share

All Articles