android / health-samples

Apache License 2.0
260 stars 148 forks source link

Example for Batching Modes #181

Open jluebbe opened 11 months ago

jluebbe commented 11 months ago

I've been trying to use batching modes as described in https://medium.com/androiddevelopers/wear-os-home-workouts-with-health-services-b9951fa9e0dc, but on my Pixel Watch 1, I only get an empty list from exerciseClient.getCapabilities().supportedBatchingModeOverrides.

Is it possible to use them with the PassiveDataCompose example? Or are they intended to be used differently?

Which devices support the 5 seconds batching mode?

breanatate commented 11 months ago

Is your Pixel Watch 1 running Wear OS 4? I believe there was an issue with batching mode support on that particular build, but a fix should be rolling out shortly.

It is not possible to use BatchingMode with PassiveMonitoringClient--it's only for Exercise. What sort of use case did you have in mind?

jluebbe commented 11 months ago

Is your Pixel Watch 1 running Wear OS 4? I believe there was an issue with batching mode support on that particular build, but a fix should be rolling out shortly.

Yes.

It is not possible to use BatchingMode with PassiveMonitoringClient--it's only for Exercise.

Ah, yes. With the new BODY_SENSORS_BACKGROUND permission, I now see that a BatchingMode is supported in ExerciseSampleCompose at least for RUNNING. I'll check if that works for me.

What sort of use case did you have in mind?

I'm trying to find some way to trigger a notification relatively quickly after a set heart rate BPM is exceeded (for pacing). With PassiveMonitoringClient, the delay is too large, so I'm looking at ExerciseSampleCompose. As the HR monitoring should be active for most of the day, I'd like to keep the battery usage as low as possible.

I also tried to set goals for a specific HR level, but it didn't seem to work.

Is there a reference for the available exercise types (like running, walking, ...) somewhere?

breanatate commented 11 months ago

I'm trying to find some way to trigger a notification relatively quickly after a set heart rate BPM is exceeded (for pacing). With PassiveMonitoringClient, the delay is too large, so I'm looking at ExerciseSampleCompose. As the HR monitoring should be active for most of the day, I'd like to keep the battery usage as low as possible.

I see. This sounds like a heart rate alert event would be helpful to have in PassiveMonitoringClient. That way, you could set HR thresholds and the app could continue to monitor in the background with low impact to battery. You mentioned the HR monitoring would be for pacing, but that it would continue for most of the day --is the primary use case for this Running?

Is there a reference for the available exercise types (like running, walking, ...) somewhere?

Yes, that's available here