dotnet / dotnet/android-libraries
HealthConnect Records do not implement IRecord
- Dominant language
- C#
- Stars
- 317
- Forks
- 73
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 17
Description
### 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'
### 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
Contributor guide
Assessment
This issue has not been assessed yet.