/// <summary>
        ///     Finishes the specified location.
        /// </summary>
        /// <param name="location">The location.</param>
        private void Finish(Location location)
        {
            var p = new Position();

            if (location.HasAccuracy)
            {
                p.Accuracy = location.Accuracy;
            }
            if (location.HasAltitude)
            {
                p.Altitude = location.Altitude;
            }
            if (location.HasBearing)
            {
                p.Heading = location.Bearing;
            }
            if (location.HasSpeed)
            {
                p.Speed = location.Speed;
            }

            p.Longitude = location.Longitude;
            p.Latitude  = location.Latitude;
            p.Timestamp = GPSServiceAndroid.GetTimestamp(location);

            if (_finishedCallback != null)
            {
                _finishedCallback();
            }

            _completionSource.TrySetResult(p);
        }
        /// <summary>
        ///     Called when the location has changed.
        /// </summary>
        /// <param name="location">The new location, as a Location object.</param>
        /// <since version="Added in API level 1" />
        /// <remarks>
        ///     <para tool="javadoc-to-mdoc">
        ///         Called when the location has changed.
        ///     </para>
        ///     <para tool="javadoc-to-mdoc"> There are no restrictions on the use of the supplied Location object.</para>
        ///     <para tool="javadoc-to-mdoc">
        ///         <format type="text/html">
        ///             <a
        ///                 href="http://developer.android.com/reference/android/location/LocationListener.html#onLocationChanged(android.location.Location)"
        ///                 target="_blank">
        ///                 [Android Documentation]
        ///             </a>
        ///         </format>
        ///     </para>
        /// </remarks>
        public void OnLocationChanged(Location location)
        {
            if (location.Provider != activeProvider)
            {
                if (activeProvider != null && manager.IsProviderEnabled(activeProvider))
                {
                    var pr     = manager.GetProvider(location.Provider);
                    var lapsed = GetTimeSpan(location.Time) - GetTimeSpan(lastLocation.Time);

                    if (pr.Accuracy > manager.GetProvider(activeProvider).Accuracy&& lapsed < timePeriod.Add(timePeriod))
                    {
                        location.Dispose();
                        return;
                    }
                }

                activeProvider = location.Provider;
            }

            var previous = Interlocked.Exchange(ref lastLocation, location);

            if (previous != null)
            {
                previous.Dispose();
            }

            var p = new Position();

            if (location.HasAccuracy)
            {
                p.Accuracy = location.Accuracy;
            }
            if (location.HasAltitude)
            {
                p.Altitude = location.Altitude;
            }
            if (location.HasBearing)
            {
                p.Heading = location.Bearing;
            }
            if (location.HasSpeed)
            {
                p.Speed = location.Speed;
            }

            p.Longitude = location.Longitude;
            p.Latitude  = location.Latitude;
            p.Timestamp = GPSServiceAndroid.GetTimestamp(location);
            PositionChanged?.Invoke(this, new PositionEventArgs(p));
        }