Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
asmq
Posts: 13
Registered: ‎12-10-2008
My Device: Not Specified

Trouble with setLocationListener()

I am testing a GPS app on a Sprint BB 8130, v. 4.3.0.71. 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:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800703/What_Is... (see section on resetting GPS).

 

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?

 

Thanks.

 

 

Please use plain text.
New Developer
asmq
Posts: 13
Registered: ‎12-10-2008
My Device: Not Specified

Re: Trouble with setLocationListener()

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?

Please use plain text.
Developer
MySpoonIs2Big
Posts: 62
Registered: ‎11-24-2008
My Device: Blackberry 9530

Re: Trouble with setLocationListener()

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? :-)

 



All code is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement.
Please use plain text.
Developer
MySpoonIs2Big
Posts: 62
Registered: ‎11-24-2008
My Device: Blackberry 9530

Re: Trouble with setLocationListener()

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.



All code is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement.
Please use plain text.