Я нашел такое решение.
etDesc.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
hastagCount = s.toString().length() - s.toString().replace("#", "").length();
if(hastagCount<=3){
previousDesc = s.toString();
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
hastagCount = s.toString().length() - s.toString().replace("#", "").length();
if(hastagCount>3){
s.clear();
s.append(previousDesc);
int pos = etDesc.getText().length();
etDesc.setSelection(pos);
etDesc.setFocusable(true);
}
}
});