Ejemplo n.º 1
0
        // Handle location updates from the location manager
        public void StartLocationUpdates()
        {
            //we can set different location criteria based on requirements for our app -
            //for example, we might want to preserve power, or get extreme accuracy


            /* var locationCriteria = new Criteria();
             * var locationProviderTest = LocMgr.AllProviders;
             * string test = locationProviderTest[0];
             * locationCriteria.Accuracy = Accuracy.Medium;
             * locationCriteria.PowerRequirement = Power.Medium;
             *
             * //get provider: GPS, Network, etc.
             * var locationProvider = LocMgr.GetBestProvider(locationCriteria, true);
             *
             * Log.Debug(logTag, string.Format("You are about to get location updates via {0}", locationProvider));*/

            var location = LocMgr.GetLastKnownLocation(LocationManager.GpsProvider);

            // Get an initial fix on location
            LocMgr.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, this);

            Device.StartTimer(TimeSpan.FromSeconds(60), () =>
            {
                Task.Run(async() => {
                    await BackgroundTask.GetGPS();

                    await Task.Delay(600000);
                });
                return(true);
            });
        }