I do not see any problems. The text from_location should change and this will happen.
Why do you "check" EditText ( from_location ) when you are inside TextWatcher code. I do not think that the value of EditText should be โstableโ when changing.
Perhaps it happens that when checking for an update, CharSequence in from_location happens, and sometimes you break it only in the middle of the change, sometimes after.
Have you checked if (CharSequence s, int start, int before, int count) returns the expected values?
As I see this situation. If you want to make any changes to the text, you must make them in the String s argument of the afterTextChanged method.
I wrote this code to check what happens by modifying the contents of an EditText , maybe this is any
mEdtText.addTextChangedListener(new TextWatcher() { private static final String TAG = "TextWatcher"; private static final boolean DEBUG = true; @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (DEBUG) Log.d(TAG, "(onTextChanged) In \"" + s + "\" " + before + " characters " + " are being replaced at " + start + " by " + count + " (" + s.subSequence(start, start + count) + ")"); if (DEBUG) Log.d(TAG, "(onTextChanged) mEdtText: \"" + mEdtText.getText() + "\""); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (DEBUG) Log.d(TAG, "(beforeTextChanged) In \"" + s + "\" " + count + " characters (" + s.subSequence(start, start + count) + ") are about to be replaced at " + start + " by " + after); if (DEBUG) Log.d(TAG, "(beforeTextChanged) mEdtText: \"" + mEdtText.getText() + "\""); } }
If you check the source code of EditText , you can see that the getText method is getText from TextView and it returns a CharSequence mText . You can sow another CharSequence mTransformed . And this is in the huge setText method there is a moment when mText is replaced by mTransformed . Probably when you call from_location getText , you get mText , and the second time you do it after setText , and you get mTransformed response.
If you want to check it out just change
CharSequence cs = from_location.getText(); Log.d(... + cs + ...); // no need to call toString as implicit call. ... Log.d(... + cs.length() + ...);