private void notifyButtonListeners(String button, double previousState) {
for (int i = 0; i < buttonListeners.size(); i++) {
if (getState(button) == TRUE && getState(button) != previousState) {
((ButtonListener) buttonListeners.elementAt(i)).buttonDown(
new SensorEvent(this,
SensorEvent.DATA_AVAILABLE,
this.state), button);
} else if (getState(button) != TRUE && getState(button) != previousState) {
((ButtonListener) buttonListeners.elementAt(i)).buttonUp(
new SensorEvent(this,
SensorEvent.DATA_AVAILABLE,
this.state),
button);
}
}