CMMotionActivityManager startActivityUpdates keep detects user activity after calling stopActivityUpdates()

こ雲淡風輕ζ 提交于 2019-12-24 01:37:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!