You can get the current animation name this way:
AnimationState state;
int trackIndex = 0;
TrackEntry entry = state.getCurrent(trackIndex);
String animationName;
if (entry == null)
animationName = null;
else
animationName = entry.getAnimation().getName();
It doesn't have to be so long, of course:
if (state.getCurrent(0) != null && state.getCurrent(0).getAnimation().getName() == "someName") { ... }
If you know the AnimationState always has a TrackEntry:
if (state.getCurrent(0).getAnimation().getName() == "someName") { ... }
You can see documentation here:
API Reference - Spine Runtimes Guide
You can set a listener using AnimationState addListener
for the whole AnimationState, or TrackEntry listener
for just one entry. Here is an example using JavaScript:
spine-runtimes/hoverboard.js at 3.8
More examples here:
spine-runtimes/spine-ts/webgl/demos at 3.8