Exemple #1
0
        public void Start(MvxLocationOptions options, Action <MvxGeoLocation> success, Action <MvxLocationError> error)
        {
            lock (this)
            {
                _locationCallback = success;
                _errorCallback    = error;

                PlatformSpecificStart(options);

                Started = true;
            }
        }
        public void Start(MvxLocationOptions options, Action<MvxGeoLocation> success, Action<MvxLocationError> error)
        {
            lock (this)
            {
                _locationCallback = success;
                _errorCallback = error;

                PlatformSpecificStart(options);

                Started = true;
            }
        }
Exemple #3
0
 protected abstract void PlatformSpecificStart(MvxLocationOptions options);
        protected override void PlatformSpecificStart(MvxLocationOptions options)
        {
            if (_googleApiClient != null)
                throw new MvxException("You cannot start MvxLocation service more than once");

            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) != ConnectionResult.Success)
                throw new MvxException("Google Play Services are not available");

            _locationRequest = LocationRequest.Create();
            _locationRequest.SetInterval((long)options.TimeBetweenUpdates.TotalMilliseconds);
            _locationRequest.SetSmallestDisplacement(options.MovementThresholdInM);
            _locationRequest.SetFastestInterval(1000);

            _locationRequest.SetPriority(options.Accuracy == MvxLocationAccuracy.Fine
                ? LocationRequest.PriorityHighAccuracy
                : LocationRequest.PriorityBalancedPowerAccuracy);

            _googleApiClient = new GoogleApiClient.Builder(this.Context)
                .AddApi(LocationServices.API)
                .AddConnectionCallbacks(_connectionCallBacks)
                .AddOnConnectionFailedListener(_connectionFailed)
                .Build();

            //_locationClient = new LocationClient(Context, _connectionCallBacks, _connectionFailed);
            //_locationClient.Connect();
            _googleApiClient.Connect();
        }
 protected abstract void PlatformSpecificStart(MvxLocationOptions options);