/// <summary>
        /// Handle when your app sleeps.
        /// </summary>
        protected override void OnSleep()
        {
            // Check the permission for location privilege
            if (PrivacyPrivilegeManager.CheckPermission("http://tizen.org/privilege/location") == CheckResult.Allow)
            {
                // Remove the handle for GeofenceEventChanged
                geofence.GeofenceEventChanged -= GeofenceEventChanged;
                // Remove the handle for StateChanged
                geofence.StateChanged -= StateChanged;
                // Remove the handle for ProximityChanged
                geofence.ProximityChanged -= ProximityChanged;
            }

            // Dispose the GeofenceManager object
            if (geofence != null)
            {
                geofence.Dispose();
            }

            perimeter = null;
            geofence  = null;

            // Set the value to the labels
            InfoLabelList[0].Text = "GeofenceManager.Dispose";
            InfoLabelList[1].Text = "Success";
        }
        /// <summary>
        /// Handle when your app resumes.
        /// </summary>
        protected override void OnResume()
        {
            /// Set the value to label
            InfoLabelList[0].Text = "new GeofenceManager and VirtualPerimeter";
            try
            {
                if (geofence == null)
                {
                    // Create the GeofenceManager object
                    geofence = new GeofenceManager();
                    // Create the VirtualPerimeter object
                    perimeter = new VirtualPerimeter(geofence);
                }

                // Set the value to label
                InfoLabelList[1].Text = "Success";

                // Check the permission for location privilege
                if (PrivacyPrivilegeManager.CheckPermission("http://tizen.org/privilege/location") == CheckResult.Allow)
                {
                    // Add a handle for GeofenceEventChanged
                    geofence.GeofenceEventChanged += GeofenceEventChanged;
                    // Add a handle for StateChanged
                    geofence.StateChanged += StateChanged;
                    // Add a handle for ProximityChanged
                    geofence.ProximityChanged += ProximityChanged;
                }
            }
            catch (Exception e)
            {
                // Set the value to label about occured exception
                InfoLabelList[1].Text = e.Message;
            }
        }
Exemple #3
0
        private static bool CheckGeofence(Coche vehiculo, Accion accion)
        {
            if (!accion.EvaluaGeocerca)
            {
                return(true);
            }

            var geocercas = GeofenceManager.GetGeocercas(vehiculo)
                            .Where(geo => geo.TipoReferenciaGeograficaId == accion.TipoGeocerca.Id)
                            .Select(geocerca => GeofenceManager.GetState(vehiculo.Id, geocerca.Id));

            var inside = false;

            foreach (var matching in geocercas)
            {
                inside |= matching != null && matching.Estado == EstadosVehiculo.Dentro;
                if (accion.DentroGeocerca && inside)
                {
                    break;
                }
            }
            return((accion.DentroGeocerca && inside) || (!accion.DentroGeocerca && !inside));
        }