Continuous Heart Rate and SpO2 Measurements - Listeners Stuck in Loop

I’m developing an application that performs periodic measurements (automatically, using AlarmManager) of heart rate and SpO2. The code responsible for these measurements is a Service that, upon initiation, launches a persistent notification and turns on the screen, allowing for accurate heart rate reading.

The application is functioning well in terms of performing periodic measurements. However, after a certain number of measurements (apparently not a standard number of times), the measurement process seems to get stuck in a sort of loop, where it doesn’t reach SpO2Status.MEASUREMENT_COMPLETED.

I’ve tried several methods to force termination after a specific time period and similar approaches, but without success. I would like to know how to work around this issue, or at least discover the reasons behind this problem.

Furthermore, I’m using two different smartwatches during my development: Samsung Galaxy Watch4 (Wear OS 3) and Samsung Galaxy Watch4 Classic (Wear OS 4), along with version 1.1.0 of the Samsung Health Privileged SDK.

I would be genuinely grateful if someone could assist me with this issue. Thank you in advance.

PS: The screenshot below is a snippet of what keeps appearing in the Logcat when the issue occurs.

I’m sorry, maybe I didn’t express myself well when I said:

The application is functioning well in terms of performing periodic measurements. However, after a certain number of measurements (apparently not a standard number of times), the measurement process seems to get stuck in a sort of loop, where it doesn’t reach SpO2Status.MEASUREMENT_COMPLETED.

What I meant is that my goal is perfectly achieved sometimes, before the “loop” occurs.
Sensor data is sent to an API. And this works sometimes. At a certain point, when starting another measurement that should be sent to the API, the measurement “never finishes.” In the Logcat, the collected values are being displayed, but it never ends. And I can’t say what causes this to happen.
A good part of my code that deals with acquiring this data was taken from Samsung’s own examples.
I’ve tried some timer approaches and the like, but I haven’t been successful.

Did you create a Developer Support request for this issue?

I think that is the best way to go.

Ron
Samsung Developer Relations