Class LocationSensor


  • public class LocationSensor
    extends Sensor
    This class provides an implementation of sensor API for obtaining GPS location. LocationSensor is a subclass of the abstract base class Sensor. It uses Android Fused Location Provider API to obtain position coordinates and updates to coordinates, as well as start and stop the location updates
    • Constructor Detail

      • LocationSensor

        public LocationSensor​(android.content.ContextWrapper appEnv)
        Creates a LocationSensor
        Parameters:
        appEnv - the application environment (e.g. an Activity or a Service)
      • LocationSensor

        public LocationSensor​(java.lang.String id,
                              android.content.ContextWrapper appEnv)
        Creates a LocationSensor
        Parameters:
        id - the identifier of this
        appEnv - the application environment (e.g. an Activity or a Service)
      • LocationSensor

        public LocationSensor​(java.lang.String id,
                              android.content.ContextWrapper appEnv,
                              int updateInterval,
                              int fastestUpdateInterval,
                              int priority)
        Creates LocationSensor
        Parameters:
        id - the identifier of this
        appEnv - the application environment (e.g. an Activity or a Service)
        updateInterval - the update interval of the location
        fastestUpdateInterval - the fastest update interval
        priority - the location reguest priority value
    • Method Detail

      • startUpdates

        public void startUpdates()
        Requests location updates
        Specified by:
        startUpdates in class Sensor
      • stopUpdates

        public void stopUpdates()
        Stops location updates
        Specified by:
        stopUpdates in class Sensor
      • getLocation

        public android.location.Location getLocation()
        Returns the last known location
        Returns:
        the Location