Class DeviceSensor
- java.lang.Object
-
- eu.h2020.helios_social.core.sensor.Sensor
-
- eu.h2020.helios_social.core.sensor.ext.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 Summary
Constructors Constructor Description DeviceSensor(android.content.Context appEnv, int sensorType)
Creates a DeviceSensorDeviceSensor(java.lang.String id, android.content.Context appEnv, int sensorType, int samplingPeriodUs, int maxReportLatencyUs, android.os.Handler handler)
Creates a DeviceSensor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasSensor()
Has related hardware sensor?boolean
isRegistered()
Is sensor registered?void
onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)
void
onSensorChanged(android.hardware.SensorEvent event)
void
startUpdates()
Starts receiving sensor data valuesvoid
stopUpdates()
Stops receiving sensor data values-
Methods inherited from class eu.h2020.helios_social.core.sensor.Sensor
finalize, getId, getSensorById, getValueListeners, receiveValue, registerValueListener, unregisterValueListener
-
-
-
-
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 environmentsensorType
- 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 interfaceandroid.hardware.SensorEventListener
-
onAccuracyChanged
public void onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)
- Specified by:
onAccuracyChanged
in interfaceandroid.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 classSensor
-
stopUpdates
public void stopUpdates()
Description copied from class:Sensor
Stops receiving sensor data values- Specified by:
stopUpdates
in classSensor
-
-