android / health-samples

Apache License 2.0
244 stars 138 forks source link

Reading Speed on Pixel Watches #235

Open Pezcraft opened 3 months ago

Pezcraft commented 3 months ago

I added the datatype SPEED to your ExerciseSampleCompose. I get the speed using an emulator but do not receive any values on my Pixel Watch 2. Is it not supported yet?

breanatate commented 3 months ago

Hello, thanks for filing an issue.

I do see Speed and Speed_Stats as supported when checking capabilities on my Pixel Watch 2. Speed is also a guaranteed data type across all Wear OS 3+ devices.

Can you share what code you are using to check the device and exercise capabilities? There is also a possibility is that the particular exercise your app is running does not support Speed on Pixel Watch 2. Off the top of my head, Swimming is an example of an exercise where the emulator supports Speed, but Pixel Watch 2 does not.

Pezcraft commented 3 months ago

I used the ExerciseSampleCompose and just replaced all DataType.CALORIES_TOTAL with DataType.SPEED. The sample is using Running which supports speed. And I removed the exercise goals in https://github.com/android/health-samples/blob/main/health-services/ExerciseSampleCompose/app/src/main/java/com/example/exercisesamplecompose/data/ExerciseClientManager.kt

breanatate commented 3 months ago

Can you share what you are seeing for a speed value? When I replace CALORIES_TOTAL and make the small adjustments for changing from an AggregateDataType to DeltaDataType (i.e. requesting the most recent value in ExerciseState.kt instead of the total), I see either 1 or 2 m/s, depending on how fast I am walking.

Depending on the goals of your Running app, I might suggest using [PACE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType#PACE()). This is because SPEED only gives you the particular speed at a specific point in time in meters/second. However, PACE will give you a value in milliseconds/kilometer, and it might be easier to observe slower/smaller values.

Pezcraft commented 3 months ago

My array is always empty but I remember that I got a very small value once. Just once and never again. When I start a Fitbit exercise I get the speed, which means that GPS works. Pace also does not deliver values. I think that the library is buggy. I will try it on my Samsung watch tomorrow.

Pezcraft commented 3 months ago

My Samsung watch is at least returning 0.0. What am I doing wrong. Can you fork this repository and send me your commit?