Advanced getHeartRateHistory questions

Former Member
Former Member
Hi guys, I have couple questions on how getHeartRateHistory works on different devices:
1. Being executed with number as first parameter (number of entries), will it return continuous values from HeartRateSample.when values perspective? Is there a chance that values will interrupt when HR monitor didn't generate values by some reason, or a I can rely that HR samples will be returned but with 0 or null value for missing moments.
2. Same question for getHeartRateHistory with Duration as first parameter.
3. Is there any proven way to determine an interval of HR sample values without iterating through all of them?
4. Does HR samples interval always constant at least for a certain device?

Essentially the question if do I need to process heart rate values before showing them as a sequence.

Thanks!
  • Hi,

    I think I can answer some of your questions, I did some experiments with the API and I came up with the following observations:
    First of all, I will assume that you were referring to getHeartRateHistory from ActivityMonitor not from SensorHistory.
    1. You can rely that the samples will return null, I haven't had a problem with it using null checking first then checking for invalid HR (HR=255) after. By the way, additional information just in case you will use SensorHistory (Temperature, Elevation and Pressure) a problem when using "number" for first parameter, I experienced memory leak that my devices had ran out of memory, I am not sure yet if this is the API problem or just my code.
    2. I only had experience with null and number as first parameter, so I cannot answer this question correctly.
    3. Yes, from my observation across all devices, the interval is dependent on the Screen Width divided 4 (4 hours) then dived 60 (60minutes).
    4. I would say Yes, it is related to answer #3.

    Well, those are just my observations and meaning they aren't accurate but I am currently using them on my app. :)

    Thanks,
    Mashake
  • I have seen the same thing as _MASHAKE_.

    With getHeartRateHistory() in ActMon vs SH history, what I've seen is that bad reading with the ActMon version returns INVALID_HR, while from SH, return a null. But to play it safe, I check for either case and treat both the same way for both calls. (The ActMon version on the va-hr at one time had a bug where it returned null instead of INVALID_HR)

    If you have access to a va-hr, I have a watchface in the store that shows the graphs for all 4 of the SensorHistory calls (Simple Graph). The HR graph is a match for the graph in the HR widget, though I do scale it a bit differently. All I do is iterate through the history, starting at the newest..