Import and display workouts
WorkoutImporter wraps the active provider and raises progress and completion
events while importing normalized WorkoutData records.
Import recent workouts
Section titled “Import recent workouts”using System.Collections.Generic;using HealthBridge;using HealthBridge.Data;using HealthBridge.Helpers;
var importer = new WorkoutImporter(HealthBridgeService.Provider);var options = ImportOptions.ForManualImport( daysBack: 14, maxWorkouts: 50);
List<WorkoutData> workouts = await importer.ImportWorkouts(options);Guard this flow with HealthBridgeService.IsReady and a non-null provider.
Display normalized fields
Section titled “Display normalized fields”Common fields include:
Id: provider record identifier.ExerciseType: normalized activity label.StartTimeandEndTime: UTC Unix milliseconds;Duration: elapsed milliseconds.- Nullable calories, distance, and steps.
Location: indoor, outdoor, or unknown.Source: contributing provider or app.TimeInHrZones: seconds per shared zone when available.
Workout read distance is expressed in kilometers. Do not confuse it with the
meter-based WorkoutWriteSample.DistanceMeters field.
Handle partial workouts
Section titled “Handle partial workouts”Platforms and source devices do not populate every metric. Hide nullable fields when absent. Do not render an unavailable value as zero.
Unknown imported iOS activity values normalize to Other; keep those workouts
visible.
Progress events
Section titled “Progress events”Subscribe in OnEnable and unsubscribe in OnDisable:
HealthBridgeEvents.OnImportStartedHealthBridgeEvents.OnWorkoutProcessedHealthBridgeEvents.OnWorkoutsImportedHealthBridgeEvents.OnImportFailed
Use these events for progress UI, but keep the awaited import result as the authoritative data returned to the caller.
Verify
Section titled “Verify”Use EditorWorkoutConfig to test complete workouts, missing optional metrics,
indoor activities, Other, and an empty list.
