I want to add X distance to the west (or north or east or north) to coordinates.
I get coordinates like this :
LocationListener locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
longitude = loc.getLongitude();
latitude = loc.getLatitude();
altitude = loc.getAltitude();
}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
I find set mock location like this:
try {
Location mockLocation = new Location(provider); // a string
mockLocation.setLatitude(latitude); // double
mockLocation.setLongitude(longitude);
mockLocation.setAltitude(altitude);
mockLocation.setTime(System.currentTimeMillis());
mockLocation.setAccuracy( Float.parseFloat("20"));
mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
locationManager_mock.addTestProvider(LocationManager.GPS_PROVIDER,
false, false, false, false, true, true, true,
Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
locationManager_mock.setTestProviderLocation(provider, mockLocation);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
toastt, Toast.LENGTH_LONG).show();
}
}
});
But I do not want to add 20 meters to west or somewhere?
thanks in advance.