问题
Am developing an app to get the user activity using CMMotionActivity. It is working fine. I also get the user activities in the following method.
CMMotionActivityManager *activityManager = [[CMMotionActivityManager alloc] init];
[activityManager startActivityUpdatesToQueue:[[NSOperationQueue alloc] init] withHandler:
^(CMMotionActivity *activity) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
];
But the issue is that, when i call the following method
[activityManager stopActivityUpdates];
it will not stop detecting the user activity. It is still working. Can you tell me that why it is happen?
Updated Question
I called start activity update by calling the following method.
-(void)StartUserActivityUpdates
{
if ([CMMotionActivityManager isActivityAvailable]) {
activityManager = [[CMMotionActivityManager alloc] init];
[activityManager startActivityUpdatesToQueue:[[NSOperationQueue alloc] init]
withHandler:
^(CMMotionActivity *activity) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}];
}}
I stop the activity update by calling following method.
-(void)StopActivityUpdates
{
activityManager = [[CMMotionActivityManager alloc] init];
[activityManager stopActivityUpdates];
}
来源:https://stackoverflow.com/questions/51136419/cmmotionactivitymanager-startactivityupdates-keep-detects-user-activity-after-ca