health-samples
health-samples copied to clipboard
SmartWatch insert record
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)) ) ) )
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.