Skip to content

HealthConnect Records do not implement IRecord #1205

@adam4fx

Description

@adam4fx

Android framework version

net9.0-android

Affected platform version

Visual Studio 17.13.6, .NET 9

Description

I am getting an error when try to insert ExerciseSessionRecord using HealthConnectClient.InsertRecords() method, which requires an IList. I can create an ExerciseSessionRecord fine, but when adding it as a parameter to InsertRecords, it becomes red underlined with the following error:

CS0029: Cannot implicitly convert type 'AndroidX.Health.Connect.Client.Records.ExerciseSessionRecord' to 'AndroidX.Health.Connect.Client.Records.IRecord'

Image

Steps to Reproduce

Add the Xamarin.AndroidX.Health.Connect.ConnectClient library to a Maui project.

Insert the code anywhere, as you can't run the app due to the error.
var client =HealthConnectClient.GetOrCreate(Platform.AppContext); var start = Java.Time.Instant.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); var end = Java.Time.Instant.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); var offset = Java.Time.ZoneOffset.From(start); var exerciseSession = new AndroidX.Health.Connect.Client.Records.ExerciseSessionRecord(start, offset, end, offset, 1); client.InsertRecords([exerciseSession], null);

Did you find any workaround?

No

Relevant log output

No relevant logs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions