BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-21-2007, 10:16 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2006
Location: Atlanta
Model: 8703e
Carrier: Sprint
Posts: 58
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default GPS Location API problem

Please Login to Remove!

having some trouble with the Location API.

So i'm finally writing an application that deals with GPS Data but its always timing out. This will run on a sprint blackberry 8703e which has a built in GPS.
Any ideas why this always times out ?

Code:
try
                {
                    // Set criteria for selecting a location provider:
                    Criteria cr= new Criteria();
                
                    // Get an instance of the provider
                    LocationProvider lp= LocationProvider.getInstance(cr);

                    // Request the location, setting a 60 second timeout
                    Location l = lp.getLocation(60); //always times out
                    Coordinates c = l.getQualifiedCoordinates();
                    double longitude = 0;
                    double latitude = 0;
                    float course = l.getCourse();
                    float speed = l.getSpeed();
                    long timestamp = l.getTimestamp();                
                    if(c != null ) 
                    {
                        // Use coordinate information
                        latitude = c.getLatitude();
                        longitude = c.getLongitude();
                    }
                     System.out.println("Lon" + longitude + " Lat "+ latitude + " course "+course+" speed "+speed+" timestamp "+timestamp);
                }
                catch(LocationException le)
                {
                    System.out.println("Location exception "+le);
                }
                catch(InterruptedException ie)
                {
                    System.out.println("Interrupted exception "+ie);
                }
__________________
Cingular BB 7290 and Sprint BB 8703e.
Offline  
Old 05-23-2007, 05:21 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

We had similar problems with default Criteria. try to define some attributes for Criteria:

Code:
cr.setCostAllowed(true);
cr.setSpeedAndCourseRequired(true);
and set timeout to 300, not 60.

Useful link:
How To - Define criteria to retrieve a GPS fix

Last edited by Skipper_Joe : 05-23-2007 at 05:22 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.