hmmm - I am trying a trivial location app, and wondering if JSR 179 really works on N95; the 'GPS' app does indeed see satellites, but the attached Midlet always times out...It does, however, consistently ask me on start-up if I want to allow it access to the positioning hardware, which I do. I just loaded this as an untrusted Midlet using the microSD card.
thanks in advance for any helpful hints!
Chris
----------------------------------------------
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.location.*;
public class Location extends MIDlet {
String error = "";
private static Display display = null;
protected void startApp() throws MIDletStateChangeException {
display = Display.getDisplay(this);
System.out.println("loading");
LocationProvider lp=null;
javax.microedition.location.Location location=null;
try {
lp= LocationProvider.getInstance(null);
} catch(LocationException e) {
addError(e);
}
String res="[RESULTS]\n";
try {
//timeout after a minute
location = lp.getLocation(60);
Coordinates coordinates = location.getQualifiedCoordinates();
res+="Altitude:"+coordinates.getAltitude()+"\n";
res+="Latitude:"+coordinates.getLatitude()+"\n";
res+="Longitude:"+coordinates.getLongitude()+"\n";
} catch(Exception e){
addError(e);
}
Form f = new Form("Results");
f.append(res);
f.append(error);
display.setCurrent(f);
}
void addError(Exception e){
e.printStackTrace();
error+=e.getMessage()+"\n";
}
protected void pauseApp() { }
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException { }
public static Display getDisplay() {
return display;
}
}

Reply With Quote

