02-11-2010 05:28 PM
What are you doing with this GPS information? Do you need a real-time display of the information? At a 5-minute gather rate, I rather doubt that. I don't see why you'd need LocationListener at all if all you're doing is getting the coordinates.According to the Developer Videos on Advanced GPS Usage, the first autonomous fix is what takes time. Every subsequent fix will have pre-emptive satelite data already, and will not require a long period of time to re-acquire the fix. I've tested this on my Bold and it seems to hold true -- I manually got my current position using BlackBerry maps every few minutes and only the first fix took more than a few seconds.
Consider the following... (The variable GPS is a LocationProvider with the criteria for an autonomous fix)
Location location = GPS.getLocation (2000);
//Get the position of the current location
QualifiedCoordinates current = location.getQualifiedCoordinates ();
double lat = current.getLatitude ();
double lon = current.getLongitude ();
As you can see, I didn't need a LocationListener at all, and these two variables now contain accurate (according to the simulator) GPS coordinates to do with what I will. I won't go into the spcifics of my application, but I basically have a background Thread that wakes up periodically to start a Thread that eventually results in gathering said GPS information.
02-11-2010 08:44 PM
@ydaraishy - Thanks!
I need to log the coordinates at the given time. The interval is variable depending on the configuration. So that's the reason why i added a listener just to keep it hot. I'm not sure if the first fix is the only one that takes time. Because if your gps hardware gets cold after a several minutes of non-activity from your gps hardware, it will automatically get cold. Then by the time you retrieved the coordinates, it will again require you some time to get a fix.
02-12-2010 09:17 AM
Do you know exactly how long it takes to go from "hot" to "cold"? You said "several minutes", which could mean that listening every say 3 minutes wouldn't allow the GPS to cool down anyway.
02-14-2010 03:53 PM
I'm not really sure how long it takes to go from hot to cold. But yes, maybe 3 minutes wouldn't cool down the GPS, but how about 30mins? or even an hour? The interval is configurable. Which can be even every 2hours or more.
02-16-2010 10:39 AM
If you're checking every 30 minutes, then there's no reason to keep the chip hot lol. In my program the interval is about 3 minutes (though eventually this will be variable), so I'm not sure if I need keep the chip hot manually. Implementing this would require a bit of an overhaul, as well as a buttload more error handling XD If I could avoid putting in a locationListener, etc, then my life becomes much easier. Hence the curiosity
02-16-2010 02:05 PM
I would suggest using the LocationListener interface. If you find it hard to pick an update interval, you may specify -1 and let the hardware update at its "native" rate (which is a bit different for every phone). Every time the locationUpdated event fires, keep the coords. And every 5 minutes send the last coords you got.
06-02-2011 07:25 AM
how did you do it without LocationListener and with just a background thread?
no idea, I've been trying but I don't achieve. Could you show the code?