I have one problem about location, my program saves app's location into firebase database, it's ok, I need to compare my location with the locations in database, I used userData object to save coordinates into it:
Location dbLocation = new Location("dbLocation");
dbLocation.setLatitude(userData.lat);
dbLocation.setLongitude(userData.lng);
and I get my location coordinates from GPSTracker service:
Location crntLocation = new Location("crntLocation");
crntLocation.setLongitude(gpstracker.getLongitude());
crntLocation.setLatitude(gpstracker.getLatitude());
I need to compare this coordinates and find distance between 2 locations
float distanceBetween = crntLocation.distanceTo(dbLocation);
but it doesn't work, I don't know why, please can you help fix it?