Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Accelemeter is not getting called

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];

[mMotionManagerstartAccelerometerUpdatesToQueue:mOperationQueuewithHandler:^(CMAccelerometerData *data, NSError *error){

dispatch_async(dispatch_get_main_queue(), ^{

//[self onDeviceMotion];

[mAccelerometerReadings addObject: data];

[selfupdateViewsWithFilteredAcceleration:data.acceleration];

});

}];



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

CLLocationManager,AGPS, GPS

Posted on Nov 16, 2012 9:01 AM

Reply
3 replies

Nov 20, 2012 10:37 AM in response to Kumar007

From the 6.0 CLLocationManager class Ref

A Boolean value indicating whether the location manager object may pause location updates.


@property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically

Discussion

Allowing the location manager to pause updates can improve battery life on the target device without sacrificing location data. When this property is set to YES, the location manager pauses updates (and powers down the appropriate hardware) at times when the location data is unlikely to change. For example, if the user stops for food while using a navigation app, the location manager might pause updates for a period of time. You can help the determination of when to pause location updates by assigning a value to the activityType property.


The default value of this property is YES.


Accelemeter is not getting called

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.