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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 11
Registered: ‎02-26-2010
My Device: Curve 8310 & Curve 8530
My Carrier: 8310 on ATT 8530 on Sprint

GPS Criteria and LocationListener Interface

I've been looking into the Criteria class when instantiating my LocationProvider which in turns registers my LocationListener


I've read this article:




and understand some more about the implementation.


I was curious if its a good practice to have two different criteria objects. One for when the GPS is fixed adn working properly and the other for when the application is waiting for the fix to come back.


I am currently looking :






public void providerStateChanged(final LocationProvider provider, final int newState)


methods for when the state changes.


When i detect a negative GPS state between those two i reset my locationlistener to a higher interval.


Should i also incorporate the above idea with two Criteria classes?


Is this a "Best Practice"?


I want to perserve the battery life but still run for long periods of time (hours)



My current development environment:

Eclipse 3.4

BlackBerry JDE Plug-in For Eclpise

Blackberry JDE Component Package

Blackberry JDE Component Package

Blackberry JDE Component Package

Blackberry JDE Component Package

Blackberry JDE Component Package

WIndow XP SP 3

Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: GPS Criteria and LocationListener Interface

If you believe the secondary criteria will allow you to KEEP a tentative GPS fix, then by all means go ahead, but if your secondary criteria is just a placeholder to do nothing while searching for a GPS fix, then I would suggest against it. I think a better plan would be to have a flag to denote whether or not you have a GPS fix, and have your location listener only try to perform its operations if the flag is true. You could periodically try to regain a fix, say at 5-minute intervals, using a background Thread. If you believe this would be too much of a drain, have a counter running that increments each time you try to acquire a fix, and have the Thread stop trying after some set number of tries, then go to sleep for another specified interval before trying again.


That's what I did for my application, anyway, but I'm no expert. Take my advice with a grain of salt.


Hope that helps,


chown -R us ./base
Posts: 11
Registered: ‎02-26-2010
My Device: Curve 8310 & Curve 8530
My Carrier: 8310 on ATT 8530 on Sprint

Re: GPS Criteria and LocationListener Interface

i have thought of that solution and seen it in an article somewhere.....


I was just curious if the criteria approach would be any better.


Thanks for your input! Smiley Very Happy