示例#1
0
        private void RegisterService()
        {
            _gpsServiceConnection = new GPSServiceConnection(_gpsBinder);
            _gpsServiceIntent     = new Intent(Android.App.Application.Context, typeof(GPSService));
            BindService(_gpsServiceIntent, _gpsServiceConnection, Bind.AutoCreate);

            _sensorConnection = new SensorConnection();
            _sensorIntent     = new Intent(Application.Context, typeof(SensorService));
            BindService(_sensorIntent, _sensorConnection, Bind.AutoCreate);
        }
示例#2
0
        public override void OnBackPressed()
        {
            base.OnBackPressed();

            _gpsServiceConnection.StopLocationUpdates();
            UnbindService(_gpsServiceConnection);
            _gpsServiceConnection = null;
            _gpsServiceIntent.Dispose();

            _sensorConnection.StopSensorService();
            UnbindService(_sensorConnection);
            _sensorConnection = null;
            _sensorIntent.Dispose();

            Finish();
        }