You need to check if the added background is an animation or not.
if(EditText1.getBackground() instanceof Animation){
//call start or stop
}else{
//leave it. this is not an animation
}
Or as a dirty solution, you can simply call the stop()
method in a try...catch
block and ignore the exception.