Class DeviceSensor

  • All Implemented Interfaces:
    android.hardware.SensorEventListener

    public class DeviceSensor
    extends Sensor
    implements android.hardware.SensorEventListener
    DeviceSensor - This class provides methods to use Android devices build-in sensors that measure motion, orientation, and various environmental conditions. This class implements the Android SensorEventListener interface {@see android.hardware.SensorEventListener} and use the Android SensorManager class {@see android.hardware.SensorManager}. For available types {@see https://developer.android.com/guide/topics/sensors/sensors_overview#sensor-availability} This class extends the base Helios Sensor class.
    See Also:
    Sensor
    • Constructor Detail

      • DeviceSensor

        public DeviceSensor​(java.lang.String id,
                            android.content.Context appEnv,
                            int sensorType,
                            int samplingPeriodUs,
                            int maxReportLatencyUs,
                            android.os.Handler handler)
        Creates a DeviceSensor
        Parameters:
        appEnv - The application environment
        sensorType - The sensor type, which should be supported be the Android platform. For available types @see https://developer.android.com/guide/topics/sensors/sensors_overview#sensor-availability (TYPE_ACCELEROMETER, TYPE_AMBIENT_TEMPERATURE,TYPE_GRAVITY,TYPE_GYROSCOPE,TYPE_LIGHT, TYPE_LINEAR_ACCELERATION,TYPE_MAGNETIC_FIELD,TYPE_ORIENTATION,TYPE_PRESSURE,TYPE_PROXIMITY, TYPE_RELATIVE_HUMIDITY,TYPE_ROTATION_VECTOR,TYPE_TEMPERATURE)
        samplingPeriodUs -
        maxReportLatencyUs -
        handler -
      • DeviceSensor

        public DeviceSensor​(android.content.Context appEnv,
                            int sensorType)
        Creates a DeviceSensor
        Parameters:
        appEnv -
        sensorType -
    • Method Detail

      • onSensorChanged

        public void onSensorChanged​(android.hardware.SensorEvent event)
        Specified by:
        onSensorChanged in interface android.hardware.SensorEventListener
      • onAccuracyChanged

        public void onAccuracyChanged​(android.hardware.Sensor sensor,
                                      int accuracy)
        Specified by:
        onAccuracyChanged in interface android.hardware.SensorEventListener
      • isRegistered

        public boolean isRegistered()
        Is sensor registered?
        Returns:
        Boolean value
      • hasSensor

        public boolean hasSensor()
        Has related hardware sensor?
        Returns:
        Boolean value
      • startUpdates

        public void startUpdates()
        Description copied from class: Sensor
        Starts receiving sensor data values
        Specified by:
        startUpdates in class Sensor
      • stopUpdates

        public void stopUpdates()
        Description copied from class: Sensor
        Stops receiving sensor data values
        Specified by:
        stopUpdates in class Sensor