Thomas Keller
Thomas Keller

Reputation: 6070

Soft keyboard looses prediction after restartInput()

I have a very weird, but consistent bug in my app with any standard Android keyboard that supports word predictions.

What I’m doing is that I call InputMethodManager.restartInput() after I evaluated the input of an EditText to show a different IME label (I check the current text with a TextWatcher and the set the label to ”Close” when the text is empty and to “Send” when it's not). Without calling restartInput() the IME label change is not taken over until the connection is otherwise renewed, e.g. by closing and reopening the keyboard again.

Now when I manually enter characters through the keyboard everything is fine as expected, labels are changed, key strokes are accepted, all good, but if I click on one of the predictions on some keyboard to paste the word, the second click on the prediction is lost (i.e. the word that should be pasted after I called restartInput()).

"Lost" means different things for different keyboards, SwiftKey for example keeps the first word underlined and then replaces that with the second word on click, while Google's keyboard just keeps the first word, ignores the second word completely and then continues with any next word.

This video shows the issue: https://puu.sh/v0WUo/8f9b3571ed.mp4

I click on “Test and the”, but the EditText only receives “Test the".

Has anybody seen this before? What am I doing wrong?

Upvotes: 2

Views: 111

Answers (0)

Related Questions