private void StartOutdoorRun() { // Create a workout configuration var configuration = new HKWorkoutConfiguration() { ActivityType = HKWorkoutActivityType.Running, LocationType = HKWorkoutSessionLocationType.Outdoor }; // Create workout session // Start workout session NSError error = null; var workoutSession = new HKWorkoutSession(configuration, out error); // Successful? if (error != null) { // Report error to user and return return; } // Create workout session delegate and wire-up events RunDelegate = new WorkoutDelegate(HealthStore, workoutSession); RunDelegate.Failed += () => { System.Diagnostics.Debug.WriteLine("Failed"); }; RunDelegate.Paused += () => { System.Diagnostics.Debug.WriteLine("Paused"); }; RunDelegate.Running += () => { System.Diagnostics.Debug.WriteLine("Running"); }; RunDelegate.Ended += () => { System.Diagnostics.Debug.WriteLine("Ended"); }; // Start session HealthStore.StartWorkoutSession(workoutSession); }
public override void HandleWorkoutConfiguration(HKWorkoutConfiguration workoutConfiguration) { // Create workout session // Start workout session NSError error = null; WorkoutSession = new HKWorkoutSession(workoutConfiguration, out error); // Successful? if (error != null) { // Report error to user and return return; } // Create workout session delegate and wire-up events RunDelegate = new WorkoutDelegate(HealthStore, WorkoutSession); RunDelegate.Failed += () => { System.Diagnostics.Debug.WriteLine("Failed"); }; RunDelegate.Paused += () => { System.Diagnostics.Debug.WriteLine("Paused"); }; RunDelegate.Running += () => { System.Diagnostics.Debug.WriteLine("Running"); }; RunDelegate.Ended += () => { System.Diagnostics.Debug.WriteLine("Ended"); }; // Start session HealthStore.StartWorkoutSession(WorkoutSession); }