Пример #1
0
        public override void OnCreate()
        {
            base.OnCreate();

            _notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

            UpdateNotification("Sensus", "");

            _sensusServiceHelper = SensusServiceHelper.Load <AndroidSensusServiceHelper>(new Geolocator(this)) as AndroidSensusServiceHelper;
            if (_sensusServiceHelper == null)
            {
                _sensusServiceHelper = new AndroidSensusServiceHelper();
                _sensusServiceHelper.Initialize(new Geolocator(this));
                _sensusServiceHelper.Save();
            }

            _sensusServiceHelper.SetService(this);

            _sensusServiceHelper.Stopped += (o, e) =>
            {
                _notificationManager.Cancel(SERVICE_NOTIFICATION_ID);
                StopSelf();
            };
        }