If I'm right you are trying to get the value of the Slider on the go.
As far as I can see there is no direct method for that, but we can utilize a Labelformatter to do so.
A Labelformatter gets the value of the Slider, modifies it and returns it so that it can be displayed in the label above the Slider. In there you can add you lines of code processing the value.
Create a Labelformatter:
formatter = new LabelFormatter() {
@NonNull
@Override
public String getFormattedValue(float value) {
//do what you want with the value in here...
return "" + value;
}
};
Afterwards just add the Labelformatter to your Slider with
slider.setLabelFormatter(formatter);
Caution: This only works when you choose to show the label on the Slider
Edit:
If you don't want the label to show up, you will have to create your own style for the label making it invisible.
Create a style in styles.xml:
<style name="LabelStyle" parent="ShapeAppearance.Material3.Tooltip"> //parent might be different for you
<item name="android:textColor">@color/transparent</item>
<item name="backgroundTint">@color/transparent</item>
</style>
Finally, add the style to the label in the xml of your layout
<com.google.android.material.slider.Slider
...
app:labelStyle="@style/LabelStyle"/>