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 booleanhasSensor()Has related hardware sensor?booleanisRegistered()Is sensor registered?voidonAccuracyChanged(android.hardware.Sensor sensor, int accuracy)voidonSensorChanged(android.hardware.SensorEvent event)voidstartUpdates()Starts receiving sensor data valuesvoidstopUpdates()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:
onSensorChangedin interfaceandroid.hardware.SensorEventListener
-
onAccuracyChanged
public void onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)- Specified by:
onAccuracyChangedin 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:SensorStarts receiving sensor data values- Specified by:
startUpdatesin classSensor
-
stopUpdates
public void stopUpdates()
Description copied from class:SensorStops receiving sensor data values- Specified by:
stopUpdatesin classSensor
-
-