03-08-2010 05:27 PM
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:
BlackBerry JDE Plug-in For Eclpise 126.96.36.199
Blackberry JDE Component Package 188.8.131.52
Blackberry JDE Component Package 184.108.40.206
Blackberry JDE Component Package 220.127.116.11
Blackberry JDE Component Package 18.104.22.168
Blackberry JDE Component Package 22.214.171.124
WIndow XP SP 3
03-09-2010 09:22 AM
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,
03-09-2010 09:30 AM
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!