Updating location only if it's more than 2 kilometers away from last sent location.
This commit is contained in:
parent
7bdd8fc0b3
commit
71a1456611
|
|
@ -94,8 +94,15 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLocation(Location newLocation){
|
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;
|
lastLocation = newLocation;
|
||||||
sendLocationToTelegram(newLocation);
|
sendLocationToTelegram(lastLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendLocationToTelegram(Location location){
|
public void sendLocationToTelegram(Location location){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue