Updating location only if it's more than 2 kilometers away from last sent location.

This commit is contained in:
Filip Strajnar 2024-10-26 12:29:13 +02:00
parent 7bdd8fc0b3
commit 71a1456611

View file

@ -94,8 +94,15 @@ public class LocationLoggingService extends Service implements LocationListener
}
private void updateLocation(Location newLocation){
if(lastLocation != null && (newLocation.distanceTo(lastLocation) < 2000))
{
Log.d(TAG, "Distance to last location too short. Ignoring.");
return;
}
lastLocation = newLocation;
sendLocationToTelegram(newLocation);
sendLocationToTelegram(lastLocation);
}
public void sendLocationToTelegram(Location location){