Observing heart rate data in Health Connect

650 Views Asked by At

I've noticed that FitBit updates Health Connect once a minute with the latest heart rate read. I was wondering if there is a way to subscribe to those updates via the new Health Connect API. The documentation around how to approach the solution is really fuzzy, and the Changes Sync API appears to be a dead link. I would prefer not to use the WorkManager, but rather just send Health Connect a Callback that would trigger if the changes to a vital sign are detected. I think that would be a better approach then polling the API every minute to see if there is something new.

What are the best practices around this?

Thank you,

I was looking to find an API on Sync Data Page and have a hard time finding the desired solution.

1

There are 1 best solutions below

0
On

Thanks for pointing out the broken link. I've submitted a correction for this, which will point to: https://developer.android.com/guide/health-and-fitness/health-connect/data-and-data-types/differential-changes-api

The Changes Sync API is a pull-based API, so you need to call getChanges() each time you want to get the latest data.

From your description, it sounds like you are after a push-based API, which unfortunately isn't available in Health Connect at this time.