/// <summary> /// Sets the last known location. /// </summary> /// <param name="location">Location to set.</param> private void SetLastKnownLocation(CLLocation location) { if (location != null) { if (this.lastKnownGeofenceLocation == null) { this.lastKnownGeofenceLocation = new GeofenceLocation(); } this.lastKnownGeofenceLocation.Latitude = location.Coordinate.Latitude; this.lastKnownGeofenceLocation.Longitude = location.Coordinate.Longitude; this.lastKnownGeofenceLocation.Accuracy = location.HorizontalAccuracy; DateTime referenceDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); referenceDate.AddSeconds(location.Timestamp.SecondsSinceReferenceDate); this.lastKnownGeofenceLocation.Date = referenceDate; } }
/// <summary> /// Sets the last known location. /// </summary> /// <param name="location">Location object.</param> internal void SetLastKnownLocation(Android.Locations.Location location) { if (location != null) { if (this.lastKnownGeofenceLocation == null) { this.lastKnownGeofenceLocation = new GeofenceLocation(); } this.lastKnownGeofenceLocation.Latitude = location.Latitude; this.lastKnownGeofenceLocation.Longitude = location.Longitude; double seconds = location.Time / 1000; this.lastKnownGeofenceLocation.Date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local).AddSeconds(seconds); } }