I want to receive a float value from DDMS but it sends an integer Example:
longitude:2.351696 latitude:48.857593
But i receive:
longitude:2.0 latitude:48.0
How can I make this work?
Here is my code:
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
if (location != null) {
Toast.makeText(this, "ma position :" + latitude + ", " + longitude,
Toast.LENGTH_LONG).show();
Log.i("latitude", "" + latitude);
Log.i("longitude", "" + longitude);
}
the Log:
03-27 09:25:20.163: I/latitude(793): 48.0 03-27 09:25:20.163: I/longitude(793): 2.0
private double getDistanceBetweenPoints(double lat1, double long2, double arrive_lat,double arrive_long) {
int R = 6371; // km
double dLat = Math.toRadians(arrive_lat - lat1);
double dLon = Math.toRadians(arrive_long - long2);
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
+ Math.cos(Math.toRadians(lat1))
* Math.cos(Math.toRadians(arrive_lat)) * Math.sin(dLon / 2)
* Math.sin(dLon / 2);
double c = 2 * Math.asin(Math.sqrt(a));
double d = R * c;
return d*1000;
}