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
Posts: 14
Registered: ‎01-25-2010
My Device: 8310
My Carrier: Digicel Jamaica
Accepted Solution

How can I reduce GPS first lock time?

I'm building an app that takes your location and calculate the distance of some specified landmarks. 

The problem I'm having is that it takes on average about 5 minutes to get he first lock. Even when I change the settings to explicitly use Assisted GPS is still takes a long time. The reason I know there must be a better approach is because Google Maps takes less than a minute to get its lock. Here's the code I used to build the Criteria:

 

 

Criteria criteria = new Criteria();
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setSpeedAndCourseRequired(false);
criteria.setAltitudeRequired(false);
criteria.setAddressInfoRequired(false);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);

 Here how I load the location:

 

 

try {
			LocationProvider provider = LocationProvider.getInstance(criteria);
			Location location = provider.getLocation(-1);
			int method = location.getLocationMethod();
			if ((method & Location.MTA_ASSISTED) == Location.MTA_ASSISTED) {
				System.out.println(" Assisted GPS");
			}
			if ((method & Location.MTA_UNASSISTED) ==
			Location.MTA_UNASSISTED) {
				System.out.println(" Unassisted GPS");
			}
			if ((method & Location.MTE_CELLID) ==
			Location.MTE_CELLID) {
				System.out.println(" Cell Site");
			}
			locationUpdated(provider, location);

		} catch (Exception e) {
			String msg = e.getMessage()+" ("+e.getClass().getName()+")";
			_mainScreen.reportError(msg);
			System.out.println(msg);
		}

 

Any idea where I'm going wrong?

 

 

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How can I reduce GPS first lock time?

Are you sure that the Google Maps fix you're talking about is obtained using the Location API at all? May be you're talking about Google's own Cellsite-style fix that doesn't use the Location API: it simply queries a web server with the current cell ID and gets an immediate response with a fix. See this post: http://supportforums.blackberry.com/t5/Java-Development/Is-it-Possible/m-p/422751#M83923

New Developer
Posts: 14
Registered: ‎01-25-2010
My Device: 8310
My Carrier: Digicel Jamaica

Re: How can I reduce GPS first lock time?

Wow! That looks really interesting. Taking a crack at it now. I'll keep you posted on my results.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How can I reduce GPS first lock time?

You may also want to check  a comment by peter_strange in that thread, where he mentions a couple of corrections that make the code work properly.

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: How can I reduce GPS first lock time?

I think first time lock time could be OS determined. For me it use to take Google Maps and BlackBerry Maps about 2 minutes (in perfect situations) to make a "lock" when I used 4.7. Now using 5.0 it is near instantaneous (roughly 2-3 seconds)... from inside a building. I know 5.0 has a new LBS "system" but it could also speed up that first lock.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Developer
Posts: 14
Registered: ‎01-25-2010
My Device: 8310
My Carrier: Digicel Jamaica

Re: How can I reduce GPS first lock time?

Most people I know are using Curves so they would be running <= 4.5. Based on my tests I'm not seeing any first lock times less than 4 minutes. While the accuracy is definitely better than the Google approach, the trade off is more than worth it in my tests. I've now modified my app to use the approach pointed out by klyubin and perter_strange and I'm getting almost instantaneous coordinates.

 

THANK YOU SO MUCH (this is gonna make my app so much better)

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How can I reduce GPS first lock time?

[ Edited ]

You're welcome! Most of the credit should go to tek3 and Google though.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: How can I reduce GPS first lock time?

P.S. It may be a good idea to let your users/customers know that Google's services are employed for obtaining a location fix. This may be inadvertently leak location information to Google.