10-14-2011 05:54 PM
I have a button listener that calls handleGPS() when the user presses it. Then the app is supposed to get the coordinates and set a text field to those coordinates. But it is not working. What am I doing wrong here?
public void handleGPS()
{
Thread ttt = new Thread(new Runnable() {
public void run() {
try{
Criteria myCriteria = new Criteria();
((BlackBerryCriteria) myCriteria).setMode(GPSInfo.GPS_MODE_ASSIST);
BlackBerryLocationProvider myProvider;
myProvider = (BlackBerryLocationProvider) LocationProvider.getInstance(myCriteria);
BlackBerryLocation myLocation;
myLocation = (BlackBerryLocation) myProvider.getLocation(300);
double lat;
double lon;
float alt;
lat = myLocation.getQualifiedCoordinates().getLatitude() ;
lon = myLocation.getQualifiedCoordinates().getLongitude( );
alt = myLocation.getQualifiedCoordinates().getAltitude() ;
String aString = Double.toString(lat);
asatrd.setText(aString);
}catch(Exception ex){
ex.printStackTrace();
System.err.println(ex.toString());
}
}
});
ttt.run();
}
FieldChangeListener funko = new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
handleGPS();
}};
10-15-2011 10:58 AM
"not working" covers quite a bit of ground. Exactly what issues are you seeing? Are you getting an exception? Have you read the GPS and Maps documentation?
You don't mention what carrier you are on - this could be an issue with network-assist mode since not all networks support this mode.