Hi,
I tried to run the application on Nokia C5-03 which is one of the GPS enabled device. But when it try to get the longotude/latitude it throws exception- "location request timed out ".
The coe I am using given below:
public static String checkLocation() throws Exception {
String string = "not found";
try {
Location l;
LocationProvider lp;
Coordinates c;
Criteria cr = new Criteria();
cr.setHorizontalAccuracy(500);
lp = LocationProvider.getInstance(cr);
l = lp.getLocation(60);
c = l.getQualifiedCoordinates();
if (c != null) {
// Use coordinate information
double lat = c.getLatitude();
double lon = c.getLongitude();
string = lat + "-" + lon;
} else {
string = "Location API failed";
}
System.out.println("location=" + string);
//display.setCurrentItem(new StringItem("lat/lon", string));
} catch (Exception e) {
System.out.println("exception in check location=" + e.getMessage());
e.printStackTrace();
return e.getMessage();
}
return string;
}
Please Help !
Thankssssss

Reply With Quote




