1 Reply Latest reply: Nov 16, 2012 8:52 AM by BenB
Kumar007 Level 1 Level 1 (0 points)

HI there,     

               I am doing a somewhat strange implementation.Here is what my application does. My application is basically using GPS data continously and using that i have to do some task. Also i have implemented Accelemeter stuff to detect device is idle or is in move.When device is in idle i am stopping gps fetching by calling "stopUpdatingLocation". and when device is in move call "startUpdatingLocation". This works fine both in foreground and background.

     But I want my application to be started(in background) when device is restarted.This works fine. I have added "voip" key in plist and in "applicationdidfinishlaunch" i have started gps fetching code and started accelemeter.

But i found that once device is kept idle (stopUpdatingLocation) , accelemeter is not getting called. Because of that i cannot detect device movement. Accelemeter callback is not getting called. Here is sample code what i have used:

 

        mMotionManager = [[CMMotionManager alloc] init];

        if (mMotionManager.accelerometerAvailable) {

            mMotionManager.accelerometerUpdateInterval = 1.0/10.0;

           mOperationQueue = [[NSOperationQueue alloc] init];

            [mMotionManager startAccelerometerUpdatesToQueue:mOperationQueue withHandler:^(CMAccelerometerData *data, NSError *error){

                dispatch_async(dispatch_get_main_queue(), ^{

                    //[self onDeviceMotion];

                    [mAccelerometerReadings addObject:  data];

                    [self updateViewsWithFilteredAcceleration:data.acceleration];

                });

            }];

 

 

Can someone help how to solve this or is this possible to do ?


CLLocationManager,AGPS, GPS