I want to send the location of the user in sms, but the problem is how do I read the co-ordinates. I have written the following code to read the co-ordinates, but it does not work. I have a nokia 6110 mobile set and I am trying on that phone. And I am writing the program in J2ME.

It is not giving me the coordinates, I tired in midlet the code it works there. can anyone tell why I am having problem to read the coordinates?

public void getLocation() throws Exception{
String location;
Location l;
LocationProvider lp;
Coordinates c;

Criteria cr= new Criteria();
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();
location = "Lat:" + lat + " Log:" + lon;
} else {
location ="Location API failed";