Note that there are some explanatory texts on larger screens.

plurals
  1. POCLLocationmanager gets stuck sometimes
    primarykey
    data
    text
    <p>I'm working on an application which periodically obtains the user's location. The big problem is that sometimes the app gets stuck, no more updates are delivered. Even if I (kill and) restart my app, nothing changes. (The accuracy values set for location manager are near 100-200 meters.) BUT, when I start the Google Maps App, in a few seconds it gets a very accurate location (which is delivered to my app to if I switch back). Why ? Here are some relevant code parts : </p> <p>The timerFiredAction is called periodically by the timer.</p> <pre><code>-(void) timerFiredAction { if (isStillWaitingForUpdate) { successiveTimerActivationCount ++; // force LM restart if value too big , e.g. 30 ( stop + start ) return; } successiveTimerActivationCount = 0 ; isStillWaitingForUpdate = YES; /* isRecordingX is always true */ if (isSignificant &amp;&amp; isRecordingSig) [self startSignificant ]; if (isGPS &amp;&amp; isRecordingGPS) [self startGps]; } // this is called in delegate method only -(void) timerStopLocationServices { isStillWaitingForUpdate = NO; if (isGPS) [ self stopGps] ; if (isSignificant) [self stopSignificant]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { // verify accuracy and stuff if ( isStillWaitingForUpdate &amp;&amp; _other_validations_ ) { // store it [self timerStopLocationServices] ; } } </code></pre> <p>The start and stop methods simply verifiy if the locationmanager is nil, if yes they call <code>createManager</code> and then call start &amp; stopUpdatingLocation.</p> <p>The creation of the LM looks like this : </p> <pre><code>-(void)createManager { @synchronized (self) { if (locationManager != nil) { [self releaseManager]; // stop timer, stop updating , reelase previous if exists } locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; double desired; // accuracy is an init param, snap to one smaller constant // generally 100-200 if (accuracy &gt;= kCLLocationAccuracyThreeKilometers) desired = kCLLocationAccuracyThreeKilometers; else if (accuracy &gt;= kCLLocationAccuracyKilometer) desired = kCLLocationAccuracyKilometer; else if (accuracy &gt;= kCLLocationAccuracyHundredMeters) desired = kCLLocationAccuracyHundredMeters; else if (accuracy &gt;= kCLLocationAccuracyNearestTenMeters) desired = kCLLocationAccuracyNearestTenMeters; else if (accuracy &gt;= kCLLocationAccuracyBest) desired = kCLLocationAccuracyBest; else if (accuracy &gt;= kCLLocationAccuracyBestForNavigation) desired = kCLLocationAccuracyBestForNavigation; locationManager.desiredAccuracy = desired; locationManager.distanceFilter = distanceFilter; } } </code></pre> <p>Did anyone experienced something like this? Any ideas are welcome :) Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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