[android] Add filtration of last location by timestamp.

This commit is contained in:
vng 2012-08-07 16:17:46 +03:00 committed by Alex Zolotarev
parent d8594f305f
commit b1724ad67d

View file

@ -185,8 +185,11 @@ public class LocationService implements LocationListener, SensorEventListener, W
final Location l = m_locationManager.getLastKnownLocation(provider);
if (l != null)
{
if (lastKnown == null || isBetterLocation(l, lastKnown))
if ((System.currentTimeMillis() - l.getTime() < FIVE_MINUTES) &&
(lastKnown == null || isBetterLocation(l, lastKnown)))
{
lastKnown = l;
}
}
}
}