Note that there are some explanatory texts on larger screens.

plurals
  1. POAccelerometer is not getting called
    text
    copied!<p>I am doing a somewhat strange implementation. My application uses GPS data continuously and using that I have to do some task. Also I have implemented accelerometer stuff to detect whether device is stationary or moving. When the device is stationary I stop GPS fetching by calling <code>stopUpdatingLocation</code>, and when device is moving I call <code>startUpdatingLocation</code>. This works fine both in the foreground and background.</p> <p>But I want my application to be started in the background when the device is restarted. This works fine. I have added "voip" key in plist and in <code>applicationDidFinishLaunch</code> I have started GPS fetching code and started accelerometer.</p> <p>But I found that once the device is kept stationary (<code>stopUpdatingLocation</code>), the accelerometer is not getting called. Because of that I cannot detect device movement. The accelerometer callback is not getting called. Here is a sample of the code I'm using:</p> <pre><code> 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]; }); }]; </code></pre> <p>Can someone help me solve this? Is it possible?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload