I have an application in which I have to plot the position of user and his friend's position on same map but problem is the positions are not accurate.For example the two coordinates like: 81.445679 25.678998 and 81.448902 25.670123. In my application I'm getting my location and then plotting the same on map but I think the type casting from double to int is making these differences.The code for that part is shown below:
locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
Location location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
int latitude = (int)(location.getLatitude() * 1000000);
int longitude = (int)(location.getLongitude() * 1000000);
point = new GeoPoint(latitude,longitude);
mapController.animateTo(point);
And to send these coordinates to user's friend I'm sending these coordinates as a string text,something like this:
private double longitude,latitude;
latitude=location.getLatitude();
longitude=location.getLongitude();
String message = latitude + " " + longitude ;
and then sending this message to user's friend and at friend side,extracting this location by breaking this message into doubles.So might be parsing from double to string and then string to double is one reason of lack of accuracy.
I'm not clear.So can anyone give me some idea about this ? Or can tell me about what kind of modifications that can be done to the existing codes ?
Thanks in advance.