07-16-2008 04:44 PM
Running on JDE 4.2.1 for the T-Mobile 8800 OS 4.2.1.103
The program is trying to return the GPS coordinates. It's a small application that I will add on to later, any help or suggestions would be helpfull.
Below is snippet of the code. The code is called from a menu selection.
// Get GPS using Autonomous
public void sGPS(){
try{
Criteria ct = new Criteria();
eType.setText("Autonomous");
ct.setHorizontalAccuracy(50);
ct.setVerticalAccuracy(50);
ct.setCostAllowed(true);
ct.setPreferredPowerConsumption(Criteria.POWER_USA
ct.setPreferredResponseTime(10000);
LocationProvider lProvider = LocationProvider.getInstance(ct);
Location loc = lProvider.getLocation(-1); // Error occurs here
eCordsLat.setText(String.valueOf(loc.getQualifiedC
eCordsLong.setText(String.valueOf(loc.getQualified
eStatus.setText("Complete");
}catch(Exception e){
System.out.println("Error Msg on geting GPS info : " + e);
}
}
07-16-2008 04:54 PM - edited 07-16-2008 04:55 PM
What is the exact error? Does it complain about not having the event lock?
If so, you'll see that error when you try to update the UI when running on a seperate thread.
I think the actual error may be the next line after getLocation(), when you call setText()...I'm guessing on a label?
07-16-2008 04:56 PM
07-16-2008 05:01 PM
In this case, you need to make sure that you are not blocking the event thread. That is, the event thread handles all drawing operations, and getLocation() is a blocking operation. Calls to getLocation() should be moved to a separate thread or alternatively, you should could use a LocationListener, which manages the threading for you.
Please see the following KB article for more information.
07-16-2008 05:04 PM - edited 07-16-2008 05:08 PM
07-16-2008 05:09 PM
I tried that and for some odd reason, The simulator returns zeros for Lat and Long.. I have values set in the Simulator[8800 T-Mobile] for GPS, but they still come back as Zero. I do get a time stamp, but no Longitude or Latitude.. When you run the simulator with values set for the GPS, you should at least get those returned, right? Or am I missing something?
07-17-2008 09:07 AM
The BlackBerry simulator should return the values for the currently selected location that is configured by clicking on the Simulate menu, then GPS Location... and then selecting a location.
Have you selected a location? Or are you simulating a route?
03-28-2012 10:52 AM
Hi every one
any body got the solution of this problem if it is please reply me
thanks in advance
03-28-2012 11:00 AM