02-27-2009 03:39 PM
I am testing a GPS app on a Sprint BB 8130, v. 220.127.116.11. A few issues that I have noticed:
- For many combinations of interval, timeout, and max_age in setLocationListener(), I get an exception ("Invalid values of interval, timeout, ...). Does anyone know on what rules I should follow to keep the values valid?
- Using -1 as defaults works, but does anyone know what those defaults are? My app needs to get updates as frequently as possible, and needs fresh locations only. I am not sure if (-1, -1, -1) achieves that.
- More importantly, setLocationListener() can easily get stuck when I momentarily lose GPS signal (e.g. go to the basement of my house). The locationProvider never returns good locations then, even when I go outside and wait for several minutes. After some Googling, I found this page:
This page recommends resetting GPS on TEMPORARILY_UNAVAILABLE event (which I never get on BB) or keeping track of the last location timestamp and resetting the provider manually. The page recommends waiting at least 3 minutes before the reset -- but that means that when GPS signal is lost, I will have a >3 minute gap in my data, which is not great.
Has anyone found a better / more reliable solution to this issue?
02-27-2009 06:42 PM
An example of invalid values is
setLocationListener(1, 2, 2)
what makes those values invalid?
Also, even with interval = 1, I only get fresh locations at most once every 2 seconds. Is there a way to get updates once a second?
02-28-2009 07:49 AM
I ran into this problem a few days ago. It took me an hour or so to realize that I hadn't read the javadocs thoroughly. The 4.7 API docs say the "setLocationListener" method will throw an IllegalArgumentException "if interval < -1, or if (interval != -1) and (timeout > interval or maxAge > interval or (timeout < 1 and timeout != -1) or (maxAge < 1 and maxAge != -1))."
So basically, if interval is not -1, timeout and maxAge must be less than interval. At the same time, timeout and maxAge can never be less than 1, unless they are -1.
Confused yet? :-)
02-28-2009 07:56 AM
Oh, and in response to your second question (refresh once per second): there is a delay associated with obtaining a GPS fix -- especially the first time you do it. I haven't played with the GPS extensively, but I thought I read some where that it can take close to two minutes to obtain an autonomous (pure GPS) fix. Even network-assisted GPS fixes can take close about 20 seconds. To get the fastest (and most accurate) fixes, I believe you'll want to stick with the autonomous mode.