Example #1
0
        public LocationProvider(Context context, ILocationListener listener)
        {
            this.context  = context;
            this.listener = listener;

            locationManager = context.GetSystemService(Context.LocationService) as LocationManager;
        }
 public GeofenceService(ILocationListener listener, IDistanceCalculatorService distanceCalculatorService, ISessionContext sessionContext)
 {
     this.Listener = listener;
     this.Listener.LocationChanged += this.OnLocationChanged;
     this.DistanceCalculatorService = distanceCalculatorService;
     this.SessionContext = sessionContext;
     this.timer = new Stopwatch();
 }
Example #3
0
 public GeofenceService(ILocationListener listener, IDistanceCalculatorService distanceCalculatorService, ISessionContext sessionContext)
 {
     this.Listener = listener;
     this.Listener.LocationChanged += this.OnLocationChanged;
     this.DistanceCalculatorService = distanceCalculatorService;
     this.SessionContext            = sessionContext;
     this.timer = new Stopwatch();
 }
 public LocationProvider(Context context, ILocationListener locListener)
 {
     this.context = context;
     this.locationManager = LocationManager.FromContext (context);
     this.locationListener = locListener;
     this.gpsProviderEnabled = this.locationManager.IsProviderEnabled (LocationManager.GpsProvider);
     this.networkProviderEnabled = this.locationManager.IsProviderEnabled (LocationManager.NetworkProvider);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ARArt.Android.LocationProvider"/> class.
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="locListener">Location listener.</param>
 public LocationProvider(Context context, ILocationListener locListener)
 {
     this.context                = context;
     this.locationManager        = LocationManager.FromContext(context);
     this.locationListener       = locListener;
     this.gpsProviderEnabled     = this.locationManager.IsProviderEnabled(LocationManager.GpsProvider);
     this.networkProviderEnabled = this.locationManager.IsProviderEnabled(LocationManager.NetworkProvider);
 }
 public static void RegisterLocationManager(this  LocationManager locationManager, ILocationListener locationListener, ICoreApplicationContext coreApplicationContext)
 {
     var criteria = new Criteria
     {
         Accuracy = Accuracy.Coarse,
         PowerRequirement = Power.Low,
     };
     var bestProvider = locationManager.GetBestProvider(criteria, true);
     var lastKnownLocation = locationManager.GetLastKnownLocation(bestProvider);
     coreApplicationContext.CurrentLocation = lastKnownLocation.ToCoordinate();
     locationManager.RequestLocationUpdates(bestProvider, 1000, 1, locationListener);
 }
Example #7
0
 public void RemoveLocationListener(ILocationListener listener)
 {
     if (listener != null)
     {
         // remove the listener and stop location updates if necessary
         locator.PositionChanged -= listener.LocationChanged;
         registeredListeners.Remove(listener);
         if (locator.IsListening && registeredListeners.Count == 0)
         {
             locator.StopListeningAsync();
         }
     }
 }
Example #8
0
        public void EnableLocationSensor(/* final */ Context pContext, /* final */ ILocationListener pLocationListener, /* final */ LocationSensorOptions pLocationSensorOptions)
        {
            this.mLocationListener = pLocationListener;

            /* final */
            LocationManager locationManager = (LocationManager)pContext.GetSystemService(Context.LocationService);
            /* final */
            String locationProvider = locationManager.GetBestProvider(pLocationSensorOptions, pLocationSensorOptions.isEnabledOnly());

            locationManager.RequestLocationUpdates(locationProvider, pLocationSensorOptions.getMinimumTriggerTime(), pLocationSensorOptions.getMinimumTriggerDistance(), this);

            this.OnLocationChanged(locationManager.GetLastKnownLocation(locationProvider));
        }
Example #9
0
 public void AddLocationListener(ILocationListener listener)
 {
     if (listener != null)
     {
         // remember the listener and start location updates if necessary
         bool needToStartLocator = !locator.IsListening && registeredListeners.Count == 0;
         registeredListeners.Add(listener);
         locator.PositionChanged += listener.LocationChanged;
         if (needToStartLocator)
         {
             locator.StartListeningAsync(AppSharedData.MinTimeBwUpdates, AppSharedData.MinDistanceChangeForUpdates);
         }
     }
 }
        public void SetLocationService(ILocationListener service = null)
        {
            _locationServiceCrossPlatformSimple =
                service ??
                LocationListener.Create();


            _locationServiceCrossPlatformSimple
            .OnError
            .Subscribe(exc =>
            {
                Error = exc.ToString();
            });

            _locationServiceCrossPlatformSimple
            .IsListeningForChanges
            .Subscribe(isListening => IsListeningForLocationChanges = isListening);
        }
Example #11
0
 internal void RequestLocationUpdates(string provider, long minTime, float minDistance, ILocationListener listener, Looper looper)
 {
     this.listener.Value = listener;
     this.provider.Value = provider;
     this.timer.Change(this.interval.Value = 1000, Timeout.Infinite);
 }
 public void RemoveLocationListener(ILocationListener listener)
 {
 }
 /// <summary>
 /// Removes the location listener.
 /// </summary>
 /// <param name="observer">Observer.</param>
 public void RemoveLocationListener(ILocationListener observer)
 {
     observers.Remove(observer);
 }
 /// <summary>
 /// Check if contains the location listener.
 /// </summary>
 /// <returns><c>true</c>, if contains location listener, <c>false</c> otherwise.</returns>
 /// <param name="observer">Observer.</param>
 public bool ContainsLocationListener(ILocationListener observer)
 {
     return(observers.Contains(observer));
 }
        public static void RegisterLocationManager(this  LocationManager locationManager, ILocationListener locationListener, ICoreApplicationContext coreApplicationContext)
        {
            var criteria = new Criteria
            {
                Accuracy         = Accuracy.Coarse,
                PowerRequirement = Power.Low,
            };
            var bestProvider      = locationManager.GetBestProvider(criteria, true);
            var lastKnownLocation = locationManager.GetLastKnownLocation(bestProvider);

            coreApplicationContext.CurrentLocation = lastKnownLocation.ToCoordinate();
            locationManager.RequestLocationUpdates(bestProvider, 1000, 1, locationListener);
        }
 /// <summary>
 /// Adds the location listener.
 /// </summary>
 /// <param name="observer">Observer.</param>
 public void AddLocationListener(ILocationListener observer)
 {
     observers.Add(observer);
 }
Example #17
0
 internal void RemoveUpdates(ILocationListener listener)
 {
     this.timer.Change(this.interval.Value = Timeout.Infinite, Timeout.Infinite);
     this.listener.Value = null;
 }
Example #18
0
 public LocationService(ILocationListener locationListener, LocationManager locationManager)
 {
     _locationListener = locationListener;
     _locationManager  = locationManager;
 }
Example #19
0
 public LocationTracker(Context context, ILocationListener locationListener)
 {
     this.context          = context;
     this.locationListener = locationListener;
 }
 public void AddLocationListener(ILocationListener listener)
 {
 }
 public static async Task <Statuses> RemoveLocationUpdatesAsync(this IFusedLocationProviderApi api, GoogleApiClient client, ILocationListener listener)
 {
     return((await api.RemoveLocationUpdates(client, listener)).JavaCast <Statuses> ());
 }
 public static async Task <Statuses> RequestLocationUpdatesAsync(this IFusedLocationProviderApi api, GoogleApiClient client, LocationRequest request, ILocationListener listener, Android.OS.Looper looper)
 {
     return((await api.RequestLocationUpdates(client, request, listener, looper)).JavaCast <Statuses> ());
 }
Example #23
0
 /**
  * @see {@link Engine#enableLocationSensor(Context, ILocationListener, LocationSensorOptions)}
  */
 protected void EnableLocationSensor(ILocationListener pLocationListener, LocationSensorOptions pLocationSensorOptions)
 {
     this.mEngine.EnableLocationSensor(this, pLocationListener, pLocationSensorOptions);
 }