health-samples icon indicating copy to clipboard operation
health-samples copied to clipboard

SmartWatch insert record

Open onix-flutter-dev opened this issue 2 years ago • 1 comments

Hello. I've tested insert record on my mobile and it works perfectly (see example). How can I insert a record from a smartwatch? Is it possible?

healthConnectClient.insertRecords( listOf( ExerciseSessionRecord( startTime = start.toInstant(), startZoneOffset = start.offset, endTime = end.toInstant(), endZoneOffset = end.offset, exerciseType = ExerciseSessionRecord.ExerciseType.SWIMMING_POOL, title = "My Swimming pool #${Random.nextInt(0, 60)}" ), HeartRateRecord( startTime = start.toInstant(), startZoneOffset = start.offset, endTime = end.toInstant(), endZoneOffset = end.offset, samples = samples ), DistanceRecord( startTime = start.toInstant(), startZoneOffset = start.offset, endTime = end.toInstant(), endZoneOffset = end.offset, distance = Length.meters((10 * Random.nextInt(20)).toDouble()) ), TotalCaloriesBurnedRecord( startTime = start.toInstant(), startZoneOffset = start.offset, endTime = end.toInstant(), endZoneOffset = end.offset, energy = Energy.calories(((140 + Random.nextInt(20)) * 0.01)) ) ) )

onix-flutter-dev avatar Sep 01 '22 10:09 onix-flutter-dev

Hello,

At this time, it is not possible to insert a record directly to Health Connect from the smartwatch.

The recommended way to pass data from the watch to Health Connect is to upload the watch data to your mobile app, then insert the record to Health Connect from the mobile app.

breanatate avatar Sep 01 '22 13:09 breanatate