Heart rate in streaming

I am using Samsung Health SDK for Android in order to obtain in streaming the heart rate beat from the wristband. The first thing I did was to download the example to count steps. Then, in the method to read the steps, I have modified the code to read the heartbeat. The code I am using for this purpose is the following:

HealthDataResolver resolver = new HealthDataResolver(mStore, null);

// Set time range from start time of today to the current time
long startTime = 16 * 60 * 60 * 1000;
long endTime = startTime + 2 * 60 * 60 * 1000;
HealthDataResolver.Filter filter = HealthDataResolver.Filter.and(
        HealthDataResolver.Filter.greaterThanEquals(HealthConstants.HeartRate.START_TIME, startTime),
        HealthDataResolver.Filter.lessThanEquals(HealthConstants.HeartRate.END_TIME, endTime));

HealthDataResolver.ReadRequest request = new ReadRequest.Builder()
            .setProperties(new String[] {HealthConstants.HeartRate.HEART_RATE})
                startTime, endTime)

try {
} catch (Exception e) {
    Log.e(MainActivity.APP_TAG, "Getting step count fails.", e);

This is the snippet I was using for getting the heart beat at 16h. It retrieves the average heart beat from 14 to 16h. Using this logic, I tried to narrow the window’s time to the last 10 seconds in order to obtain the heart beat in streaming. The problem is that when I reduce this window to lower than one hour, it retrieves a zero value. Therefore, I am not sure if this is the best way to achieve this and, if so, how can I do it in order to obtain in my app the heartbeat in streaming.


You know, your idea is great, but I have the problem that my steps are counting incorrectly. Does this code that you provided could be modifies to make the app work?

Hi, cel. What you are asking is unrelated with my question, I was asking regarding getting the heart rate beat on streaming. Nevertheless, the code of this repository worked for me.