Example #1
0
        public void StartMonitoring()
        {
            if (CMMotionActivityManager.IsActivityAvailable)
            {
                activityManager.StartActivityUpdates(MotionQueue, activity => {
                    if (!activity.HasActivitySignature())
                    {
                        return;
                    }
                    SaveMotionActivity(activity);
                    UpdateUserContext();
                });
            }
            else
            {
                WriteLine("Activity updates are not available.");
            }

            if (CMPedometer.IsStepCountingAvailable)
            {
                pedometer.StartPedometerUpdates(NSDate.Now, (pedometerData, error) => {
                    if (pedometerData != null)
                    {
                        SavePedometerData(pedometerData);
                        UpdateUserContext();
                    }
                    else if (error != null)
                    {
                        HandleError(error);
                    }
                });
            }
            else
            {
                WriteLine("Step counting is not available.");
            }
        }
 static void PlatformStart()
 {
     _manager.StartActivityUpdates(new NSOperationQueue(), OnCMMotionActivity);
 }
Example #3
0
 public void StartMotionUpdates(Action <ActivityType> handler)
 {
     motionActivityMgr.StartActivityUpdates(NSOperationQueue.MainQueue, ((activity) => {
         handler(ActivityDataManager.ActivityToType(activity));
     }));
 }