Hi!! 
I am trying to get the distance between two points, but the result i'm getting is incorrect.
My problem is I am using a real device and an emulator. So I'm getting the coordinates of my device and am sending dummy coordinates to my emulator for testing. My problem is that I get 9. something no matter what dummy coordinates I send.
I send Client A's coordinates in a string format as below:
[HIGH]coordinates = (latitude + "," + longitude);[/HIGH]
I then split that string, and parse for doubles as below:
[HIGH]String[] Loc = location.split(",");
Clatitude = Double.parseDouble(Loc[0]);
Clongitude = Double.parseDouble(Loc[1]);[/HIGH]
Below I try to get the distance between the two points:
[HIGH]public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Location parent = new Location("parent");
Platitude = location.getLatitude();
Plongitude = location.getLongitude();
parent.setLatitude(Platitude / 1e6);
parent.setLongitude(Plongitude / 1e6);
Location child = new Location("child");
child.setLatitude(Clatitude / 1e6);
child.setLongitude(Clongitude / 1e6);
distance = parent.distanceTo(child);
String distanceSt = String.valueOf(distance);
TextView myTextview = (TextView) findViewById(R.id.distTo);
myTextview.setText(distanceSt);
}
}[/HIGH]
I'm not sure if it's an issue with my code or if it's an issue with the way I'm trying to display the distance?
Any help on this would be greatly appreciated, I'm not too experienced, I teaching myself with the help of these forums.
Regards,
Gary
*****EDIT*****
after further testing I can rule out problems with the split string with the following code:
[HIGH]Clatitude = Double.valueOf(currLocation[0]);
clat = String.valueOf(Clatitude);
Clongitude = Double.valueOf(currLocation[1]);
clong = String.valueOf(Clongitude);[/HIGH]
I then displayed them in a text view for testing, and they're both correct
[HIGH]TextView myTextview = (TextView) findViewById(R.id.dist);
myTextview.setText(clong);[/HIGH]
So now that I've established that it's not the split or the parsing that is the problem, would anyone have any other ideas? Could it be on the end of the emulator?

I am trying to get the distance between two points, but the result i'm getting is incorrect.
My problem is I am using a real device and an emulator. So I'm getting the coordinates of my device and am sending dummy coordinates to my emulator for testing. My problem is that I get 9. something no matter what dummy coordinates I send.
I send Client A's coordinates in a string format as below:
[HIGH]coordinates = (latitude + "," + longitude);[/HIGH]
I then split that string, and parse for doubles as below:
[HIGH]String[] Loc = location.split(",");
Clatitude = Double.parseDouble(Loc[0]);
Clongitude = Double.parseDouble(Loc[1]);[/HIGH]
Below I try to get the distance between the two points:
[HIGH]public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Location parent = new Location("parent");
Platitude = location.getLatitude();
Plongitude = location.getLongitude();
parent.setLatitude(Platitude / 1e6);
parent.setLongitude(Plongitude / 1e6);
Location child = new Location("child");
child.setLatitude(Clatitude / 1e6);
child.setLongitude(Clongitude / 1e6);
distance = parent.distanceTo(child);
String distanceSt = String.valueOf(distance);
TextView myTextview = (TextView) findViewById(R.id.distTo);
myTextview.setText(distanceSt);
}
}[/HIGH]
I'm not sure if it's an issue with my code or if it's an issue with the way I'm trying to display the distance?
Any help on this would be greatly appreciated, I'm not too experienced, I teaching myself with the help of these forums.
Regards,
Gary
*****EDIT*****
after further testing I can rule out problems with the split string with the following code:
[HIGH]Clatitude = Double.valueOf(currLocation[0]);
clat = String.valueOf(Clatitude);
Clongitude = Double.valueOf(currLocation[1]);
clong = String.valueOf(Clongitude);[/HIGH]
I then displayed them in a text view for testing, and they're both correct
[HIGH]TextView myTextview = (TextView) findViewById(R.id.dist);
myTextview.setText(clong);[/HIGH]
So now that I've established that it's not the split or the parsing that is the problem, would anyone have any other ideas? Could it be on the end of the emulator?
