private void Stop()
        {
            StopLocationUpdates();

            StopForeground(true);
            IsStarted = false;

            WorkManager.Instance.CancelAllWork();
            //WorkManager.Instance.CancelUniqueWork("GpsTrackerUploaderWorker");

            //var settings = _settingsService.GetSettings();

            var request = OneTimeWorkRequest
                          .Builder
                          .From <UploaderWorker>()
                          //.SetConstraints(GetConstraints(settings))
                          .Build();

            WorkManager.Instance.EnqueueUniqueWork("GpsTrackerUploaderWorkerOneTime", ExistingWorkPolicy.Keep, request);

            var notificationManager = NotificationManagerCompat.From(Application.Context);

            notificationManager.CancelAll();

            if (_customNetworkCallback != null)
            {
                ConnectivityManager.UnregisterNetworkCallback(_customNetworkCallback);
                _customNetworkCallback = null;
            }
        }
        private void Start()
        {
            var settings = _settingsService.GetSettings();

            StartLocationUpdates();

            var builder = new NetworkRequest.Builder();

            builder.AddTransportType(TransportType.Wifi);
            var networkRequest = builder.Build();

            _customNetworkCallback = new CustomNetworkCallback((WifiManager)GetSystemService(WifiService), StartLocationUpdates, StopLocationUpdates);
            ConnectivityManager.RegisterNetworkCallback(networkRequest, _customNetworkCallback);

            if (settings.IsEmailSendingEnabled)
            {
                var request = PeriodicWorkRequest
                              .Builder
                              .From <UploaderWorker>(TimeSpan.FromMinutes(settings.EmailSendingInterval))
                              //.SetBackoffCriteria(BackoffPolicy.Linear, TimeSpan.FromMinutes(5))
                              .SetConstraints(GetConstraints(settings))
                              .Build();

                WorkManager.Instance.EnqueueUniquePeriodicWork("GpsTrackerUploaderWorker", ExistingPeriodicWorkPolicy.Keep, request); // TODO: ExistingPeriodicWorkPolicy.Replace?
            }

            IsStarted = true;
        }