how can i update this code so that it will display an update of the gps every 5 second
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">
/**
* Returns an initiliazed instance of stringItem component.
* @return the initialized component instance
*/
public StringItem getStringItem() {
if (stringItem == null) {
// write pre-init user code here
stringItem = new StringItem("Hello", "Hello, World!");
locateme ();
}
return stringItem;
}
//</editor-fold>
public void locateme () {
try { Criteria cr = new Criteria();
cr.setHorizontalAccuracy(500);
LocationProvider lp = LocationProvider.getInstance(cr);
Location l = lp.getLocation(60);
Coordinates c = l.getQualifiedCoordinates();
if (c != null) {
String lat = c.convert(c.getLatitude(),c.DD_MM);
if (c.getLatitude() > 0) {
lat = "E " + lat;
} else {
lat = "W " + lat;
}
String lon = c.convert(c.getLongitude(),c.DD_MM);
if (c.getLongitude() > 0) {
lon = "N " + lon;
} else {
lon = "S " + lon;
}
stringItem = new StringItem("Hello", "Hello, World!");
stringItem.setText("\nYour present location is \n" + lat + "\n" + lon);
}
} catch (Exception e) { //LocationException OR InterruptedException
}}

Reply With Quote

