Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-08-2008, 11:26 AM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 1
gbhatnag is on a distinguished road
Default CLLocationManager stopUpdatingLocation not working?

I am working on an application that uses the phone's current location. I've created a class that has a CLLocationManager instance and implements the CLLocationManagerDelegate protocol to get location updates.

Once I receive a "valid" location update (based on how recent or accurate the location update is), I want the locationManager to stop sending updates. I do this by calling:
Code:
[locationManager stopUpdatingLocation]
After the stopUpdatingLocation call, there is no way that startUpdatingLocation can be called again.

On the simulator, this works fine (perhaps because there is only one hard-coded location: Cupertino). On a device, this does not work and I continue to get updates even after the stopUpdatingLocation call.

Anybody have similar problems? Is this a bug, or, am I missing something about the way CLLocationManager's startUpdatingLocation and stopUpdatingLocation work? Thanks very much.
gbhatnag is offline   Reply With Quote
Old 01-19-2009, 02:03 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 4
debug77 is on a distinguished road
Default

I've got exactly the same problem. Did you ever get to the bottom of it, or did anyone else?
debug77 is offline   Reply With Quote
Old 04-13-2009, 10:09 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: Melbourne, Australia
Posts: 54
greenflame is on a distinguished road
Default

*BUMP*
greenflame is offline   Reply With Quote
Old 06-12-2009, 12:15 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 24
S.LakshmiKanth Reddy is on a distinguished road
Default CLLocationManager is not updating

i am facing the problem , like CLLocationManager is returning me the same old location that it got when the application has started.

can anyone help me out in solving this issue.
S.LakshmiKanth Reddy is offline   Reply With Quote
Old 06-14-2009, 05:13 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: Melbourne, Australia
Posts: 54
greenflame is on a distinguished road
Default

Quote:
Originally Posted by S.LakshmiKanth Reddy View Post
i am facing the problem , like CLLocationManager is returning me the same old location that it got when the application has started.

can anyone help me out in solving this issue.
Depends on where you are calling startUpdatingLocation.

Also make sure you have implemented...

- (void)locationManagerCLLocationManager *)manager didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)oldLocation

This method recognises when the current location has changed. Use this method to detect whether the current location is getting updated.
greenflame is offline   Reply With Quote
Old 06-14-2009, 11:04 PM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 20
Danny is on a distinguished road
Default

Quote:
Originally Posted by greenflame View Post
Depends on where you are calling startUpdatingLocation.

Also make sure you have implemented...

- (void)locationManagerCLLocationManager *)manager didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)oldLocation

This method recognises when the current location has changed. Use this method to detect whether the current location is getting updated.
In didUpdateToLocation you have check old location and new location difference
but when update start you have to wait for some time then you have to check
Danny is offline   Reply With Quote
Old 06-15-2009, 12:55 AM   #7 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 24
S.LakshmiKanth Reddy is on a distinguished road
Default

Quote:
Originally Posted by greenflame View Post
Depends on where you are calling startUpdatingLocation.

Also make sure you have implemented...

- (void)locationManagerCLLocationManager *)manager didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)oldLocation

This method recognises when the current location has changed. Use this method to detect whether the current location is getting updated.

yes, i have implemented the CLLocationManagerDelegate and implemented this method even then i am not getting the updated location, i am getting the location only when i have launched the application later if i try to update then i am getting the old location only.

This is my problem, if u can help anyway it is greatly appreciable.
S.LakshmiKanth Reddy is offline   Reply With Quote
Old 06-19-2009, 11:16 AM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 557
Joseph Nardone is on a distinguished road
Default Did anyone answer original question?

Hi:
Did anyone find the answer to whether or not stopUpdatingLocation works as its name implies. I call it but then I still get updated locations!!

Has everyone just been programming around it?

I keep recalling startUpdatingLocation until my horizontal accuracy reaches the desired level and then i call stopUpdatingLocation and proceed. With the phone stationary I get 2 extra updates.
Joseph Nardone is offline   Reply With Quote
Old 08-14-2009, 03:09 PM   #9 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 1
site_reg is on a distinguished road
Default Fixed with a static BOOL variable as a flag

I was having the same problem, and it seems to be fixed by declaring a static BOOL in your .m file and checking it when you enter the didUpdateToLocation method.

Code:
@implementation MyFile
@synthesize MySynth;
static BOOL haveAlreadyReceivedCoordinates = NO;
Then in your didUpdateToLocation method:

Code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if(haveAlreadyReceivedCoordinates) {
	return;
	}
haveAlreadyReceivedCoordinates = YES;
...
}
This won't technically make it stop receiving updates, but it will ignore any updates after the first one. If your app depends on getting just one location update to do its work, this should help. :-)
site_reg is offline   Reply With Quote
Old 11-05-2009, 10:51 AM   #10 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 1
RayKrueger is on a distinguished road
Default My solution

I ran into the same issue just this morning.
I resorted to setting and unsetting the delegate as needed.

self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];

And then when I stop it...
self.locationManager.delegate = nil;
[self.locationManager stopUpdatingLocation];

In my scenario it isn't that stopUpdatingLocation doesn't work, it's that all instances of CLLocationManager get updated by every instance of CLLocationManager. In my case, the one I created was getting called by the one created in the MapView. Nasty.
RayKrueger is offline   Reply With Quote
Old 11-05-2009, 02:14 PM   #11 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
jsd is on a distinguished road
Default

stopUpdatingLocation does indeed make it stop, but you will get two calls to didUpdateToLocation even if you say stop the first time it is called. Not sure if this is a bug or a feature.
jsd is offline   Reply With Quote
Old 01-20-2010, 12:09 AM   #12 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 17
bleasdell is on a distinguished road
Default Worked for me

Quote:
Originally Posted by site_reg View Post
I was having the same problem, and it seems to be fixed by declaring a static BOOL in your .m file and checking it when you enter the didUpdateToLocation method.

Code:
@implementation MyFile
@synthesize MySynth;
static BOOL haveAlreadyReceivedCoordinates = NO;
Then in your didUpdateToLocation method:

Code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if(haveAlreadyReceivedCoordinates) {
	return;
	}
haveAlreadyReceivedCoordinates = YES;
...
}
This won't technically make it stop receiving updates, but it will ignore any updates after the first one. If your app depends on getting just one location update to do its work, this should help. :-)
Thanks Site_reg. Your suggestion worked for me.
bleasdell is offline   Reply With Quote
Old 11-05-2010, 12:57 PM   #13 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 10
sebastien is on a distinguished road
Default

Hi, I am trying to get stopUpdatingLocation working for an iphone application but it is not working. I declared a static BOOL in my .m file but it is still updating, I dont know why. I dont know what I am doing wrong.
__________________
Apple store : enemy of friend ?
iphone casino

Last edited by sebastien; 11-05-2010 at 01:03 PM.
sebastien is offline   Reply With Quote
Old 10-18-2011, 07:17 AM   #14 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 20
Danny is on a distinguished road
Default Question regarding the app store release

Hi friends,

I've query regarding the app store release. our client previously use other app store account for release his app on app store. Now we develop next version of same app for same client. we want upload updated version of app using our apple account. My question is if older version of app deactive from older apple account & upload updated new version same app using our account.Will the older user thoughs already have old version of app gets notification?

Thanks,
Dan
Danny is offline   Reply With Quote
Old 10-18-2011, 08:07 AM   #15 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Danny View Post
Hi friends,

I've query regarding the app store release. our client previously use other app store account for release his app on app store. Now we develop next version of same app for same client. we want upload updated version of app using our apple account. My question is if older version of app deactive from older apple account & upload updated new version same app using our account.Will the older user thoughs already have old version of app gets notification?

Thanks,
Dan
Open a new thread for this. It certainly does not belong in a thread about location manager. It doesn't even belong in a development forum, since it's an app store procedural question. It belongs in the Business/legal/app store forum:

http://www.iphonedevsdk.com/forum/bu...gal-app-store/
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
cllocation, cllocationmanager, location, stopupdatinglocation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 322
10 members and 312 guests
chiataytuday, coolman, givensur, ipodphone, jbro, mottdog, mtl_tech_guy, Punkjumper, vilisei, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,882
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0