Okay so you gotta update your Locations with setTime()
and setElapsedRealtimeNanos()
.
A complete create method for a location will look something like following:
@SuppressLint("NewApi")
public Location createLocation(double lat, double lng, float accuracy) {
// Create a new Location
Location newLocation = new Location(PROVIDER);
newLocation.setLatitude(lat);
newLocation.setLongitude(lng);
newLocation.setAccuracy(accuracy);
newLocation.setTime(System.currentTimeMillis());
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
newLocation.setElapsedRealtimeNanos(
SystemClock.elapsedRealtimeNanos());
}
return newLocation;
}
This has been tested to work with Nexus 5.