This is common behavior of this method. You need to handle using flag.
Use this code
private TextWatcher mTextEditorWatcher = new TextWatcher() {
boolean flag = false;
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() == 10) {
if (!flag) {
messageBody.setImeOptions(EditorInfo.IME_ACTION_DONE);
AlertDialog.Builder alert = new AlertDialog.Builder(
SendSms.this);
alert.setMessage("You Cross the limit of 10 Words !");
alert.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alert.show();
}
flag = true;
} else {
flag = false;
}
}
});
Other references
TextWatcher events are being fired multiple times
Events of TextWatcher are being called twice
Better is to use setError. Read how to use it.