/// <inheritdoc />
        protected override void OnStart()
        {
            base.OnStart();
            PreferenceManager.GetDefaultSharedPreferences(this)
            .RegisterOnSharedPreferenceChangeListener(this);

            _requestLocationUpdatesButton = (Button)FindViewById(Resource.Id.request_location_updates_button);
            _removeLocationUpdatesButton  = (Button)FindViewById(Resource.Id.remove_location_updates_button);

            _requestLocationUpdatesButton.SetOnClickListener(new OnClickListener(view =>
            {
                if (!CheckPermissions())
                {
                    RequestPermissions();
                }
                else
                {
                    _service.RequestLocationUpdates();
                }
            }));

            _removeLocationUpdatesButton.SetOnClickListener(new OnClickListener(view =>
            {
                _service.RemoveLocationUpdates();
            }));

            // Restore the state of the buttons when the activity (re)launches.
            SetButtonsState(Utils.RequestingLocationUpdates(this));

            if (_serviceConnection == null)
            {
                _serviceConnection = new ServiceConnection((name, binder) =>
                {
                    var serviceBinder = (LocationUpdatesServiceBinder)binder;
                    _service          = serviceBinder.Service;
                    _isBound          = true;
                },
                                                           name =>
                {
                    _service = null;
                    _isBound = false;
                });
            }

            // Bind to the service. If the service is in foreground mode, this signals to the service
            // that since this activity is in the foreground, the service can exit foreground mode.
            BindService(new Intent(this, typeof(LocationUpdatesService)), _serviceConnection, Bind.AutoCreate);
        }
 public LocationUpdatesServiceBinder(LocationUpdatesService service)
 {
     Service = service;
 }