For example, send a backspace key to the edit text control to remove a character or send a char code like 112 to append a character in the edittext control programmatically.
I think you need use addTextChangedListener to EditText. Refer the answer of EditText input with pattern android and Live editing of users input
addTextChangedListener
EditText