I have declared in my fragment a textInputLayout which contains an edit text with parameters
android:inputType="textCapCharacters"
android:maxLength="3"
android:maxLines="1"
and it works correctly on most devices, it "survives" while user is trying to input more than 3 characters, but IF user tries to paste a string, which contains more than 3 characters it ends up crashing.
"java.lang.IndexOutOfBoundsException: setSpan (0 ... 10) ends beyond length 3"
and just to be clear, the app doesn't crash after pasting longer strings on most of the devices but on some it does, and thus is why I'm here, is there any way I could prevent that?
You Could use the CLIPBOARD_SERVICE on your fragment as stated here , enable the editing (only if it's plain text), finally do a string.take(3)
and assign that to your text property on the textInputLayout.