コード例 #1
0
        protected override void OnHandleIntent(Intent intent)
        {
            if (LocationClient.HasError(intent))
            {
                Log.Debug(TAG, "Location Services error");
                StartActivity(new Intent(this, typeof (AlarmErrorScreen)).AddFlags(ActivityFlags.NewTask));
            }
            else
            {
                Log.Debug(TAG, "Location Services success");

                var geofences = LocationClient.GetTriggeringGeofences(intent);
                if (geofences == null || geofences.Count <= 0) return;
                var requestId = geofences[0].RequestId;

                var dbManager = new DBManager();
                var alarm = dbManager.GetAlarmByGeofenceRequestId(requestId);

                if (alarm == null) return;

                StartActivity(intent.SetClass(this, typeof (AlarmScreen))
                    .AddFlags(ActivityFlags.NewTask)
                    .PutExtra(Constants.AlarmsData_Extra, JsonConvert.SerializeObject(alarm)));
                StartService(new Intent(this, typeof (UIWhileRingingIntentService))
                    .SetAction(UIWhileRingingIntentService.StartAlarmAction)
                    .PutExtra(Constants.AlarmsData_Extra, JsonConvert.SerializeObject(alarm)));
            }
        }
コード例 #2
0
		public override void OnReceive (Context context, Intent intent)
		{
			Log.Debug ("PhoneBootedBroadcastReceiver", "ActionBootCompleted received");

			var activeAlarms = new DBManager ().GetAll ().Where (alarm => alarm.Enabled).ToList ();

			if (activeAlarms != null && activeAlarms.Count > 0) {
				context.StartService (new Intent (context, typeof(RestoreAfterRebootService)));
			}
		}
コード例 #3
0
		void RestoreGeofences ()
		{
			_dbManager = new DBManager ();
			_activeAlarms = _dbManager.GetAll ().Where (alarm => alarm.Enabled).ToList ();
			_dbManager.EnableAlarms (_activeAlarms, false);

			_geofenceManager = new GeofenceManager ();
			_geofenceManager.Error += (sender, e) => AnyError ();
			_geofenceManager.Started += HandleStarted;
			_geofenceManager.FailedToStart += (sender, e) => AnyError ();
			_geofenceManager.FailedToStartWithResolution += (sender, e) => AnyError ();
			_geofenceManager.Stoped += HandleStoped;
			_geofenceManager.GeofenceAdded += HandleGeofenceAdded;

			_geofenceManager.Start ();
		}
コード例 #4
0
		public override void OnDestroy ()
		{
			Log.Debug (TAG, "OnDestroy");

			if (_geofenceManager != null) {
				_geofenceManager.GeofenceAdded -= HandleGeofenceAdded;
				_geofenceManager.Stoped -= HandleStoped;
				_geofenceManager.Started -= HandleStarted;

				_geofenceManager = null;
			}

			_dbManager = null;

			base.OnDestroy ();
		}