How to validate a button is being pressed (java)?

The scenario is, i have a button when i press and hold it starts to record a voice note, how can i validate the button is being pressed ?! the element pressed and unpressed has the same values attributes except for the text.

The element should have more attributes, check what is changing when the button is pressed. Like selected, focused, checked…