Class LocationContext

  • All Implemented Interfaces:
    SensorValueListener

    public class LocationContext
    extends Context
    implements SensorValueListener
    LocationContext - a location-based context class.
    This class extends the base class Context, and it is defined by location center coordinates and radius. Location value updates are obtained from LocationSensor via SensorValueListener
    • Constructor Detail

      • LocationContext

        public LocationContext​(java.lang.String name,
                               double lat,
                               double lon,
                               double radius)
        Creates a LocationContext. The context is defined by the latitude (lat) and longitude (lon) values and the radius, and is active in the circular area defined by center coordinates (lat, lon) and radius.
        Parameters:
        name - the name of the context
        lat - the latitude value of the center point
        lon - the longitude value of the center point
        radius - the radius of the circle
      • LocationContext

        public LocationContext​(java.lang.String id,
                               java.lang.String name,
                               double lat,
                               double lon,
                               double radius)
        Creates a LocationContext. The context is defined by the latitude (lat) and longitude (lon) values and the radius, and is active in the circular area defined by center coordinates (lat, lon) and radius.
        Parameters:
        id - the identifier of the context
        name - the name of the context
        lat - the latitude value of the center point
        lon - the longitude value of the center point
        radius - the radius of the circle
    • Method Detail

      • getLat

        public double getLat()
        Gets the latitude value of this context
        Returns:
        the latitude value
      • setLat

        public void setLat​(double lat)
        Sets the latitude value (lat) of this context
        Parameters:
        lat - the latitude
      • getLon

        public double getLon()
        Gets the longitude value (lon) of this context
        Returns:
        the longitude value
      • setLon

        public void setLon​(double lon)
        Sets the longitude value (lon) of this context
        Parameters:
        lon - the longitude
      • getRadius

        public double getRadius()
        Gets the radius of this context
        Returns:
        the radius value
      • setRadius

        public void setRadius​(double radius)
        Sets the radius value
        Parameters:
        radius - the radius value
      • updateLocation

        public void updateLocation​(android.location.Location location)
        Updates the current location value
        Parameters:
        location - the updated location
      • getLocation

        public android.location.Location getLocation()
        Gets the current location value
        Returns:
        the location
      • receiveValue

        public void receiveValue​(java.lang.Object value)
        Receives location value from LocationSensor. This method implements the SensorValueListener interface method, which is called when the related sensor obtains updated location value.
        Specified by:
        receiveValue in interface SensorValueListener
        Parameters:
        value - the received Location value