Sensor class
Class representing a sensor. Use {@link SensorManager#getSensorList} to get the list of available sensors. For more information about Android sensors, read the Motion Sensors guide.
@see SensorManager @see SensorEventListener @see SensorEvent
Constructors
- Sensor({required String name, required String vendor, required int version, required int type, required double maxRange, required double resolution, required double power, required int minDelay, int? reportingMode, bool? isDynamicSensor, bool? isWakeUpSensor, int? fifoReservedEventCount, int? fifoMaxEventCount, String? stringType, int? maxDelay, int? id})
-
const
- Sensor.fromJson(String source)
-
factory
-
Sensor.fromMap(Map<
String, dynamic> map) -
factory
Properties
- fifoMaxEventCount → int?
-
@return Maximum number of events of this sensor that could be batched. If this value is zero
it indicates that batch mode is not supported for this sensor. If other applications
registered to batched sensors, the actual number of events that can be batched might be
smaller because the hardware FiFo will be partially used to batch the other sensors.
final
- fifoReservedEventCount → int?
-
@return Number of events reserved for this sensor in the batch mode FIFO. This gives a
guarantee on the minimum number of events that can be batched.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → int?
-
@return The sensor id that will be unique for the same app unless the device is factory
reset. Return value of 0 means this sensor does not support this function; return value of -1
means this sensor can be uniquely identified in system by combination of its type and name.
final
- isDynamicSensor → bool?
-
Returns true if the sensor is a dynamic sensor.
final
- isWakeUpSensor → bool?
-
Returns true if the sensor is a wake-up sensor.
final
- maxDelay → int?
-
This value is defined only for continuous and on-change sensors. It is the delay between two
sensor events corresponding to the lowest frequency that this sensor supports. When lower
frequencies are requested through registerListener() the events will be generated at this
frequency instead. It can be used to estimate when the batch FIFO may be full. Older devices
may set this value to zero. Ignore this value in case it is negative or zero.
final
- maxRange → double
-
@return maximum range of the sensor in the sensor's unit.
final
- minDelay → int
-
@return the minimum delay allowed between two events in microseconds
or zero if this sensor only returns a value when the data it's measuring
changes. Note that if the app does not have the
{@link android.Manifest.permission#HIGH_SAMPLING_RATE_SENSORS} permission, the
minimum delay is capped at 5000 microseconds (200 Hz).
final
- name → String
-
@return name string of the sensor. The name is guaranteed to be unique
for a particular sensor type.
final
- power → double
-
@return the power in mA used by this sensor while in use
final
- reportingMode → int?
-
Each sensor has exactly one reporting mode associated with it. This method returns the
reporting mode constant for this sensor type.
final
- resolution → double
-
@return resolution of the sensor in the sensor's unit.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringType → String?
-
@return The type of this sensor as a string.
final
- type → int
-
@return generic type of this sensor.
final
- vendor → String
-
@return vendor string of this sensor.
final
- version → int
-
@return version of the sensor's module.
final
Methods
-
copyWith(
{String? name, String? vendor, int? version, int? type, double? maxRange, double? resolution, double? power, int? minDelay, int? reportingMode, bool? isDynamicSensor, bool? isWakeUpSensor, int? fifoReservedEventCount, int? fifoMaxEventCount, String? stringType, int? maxDelay, int? id}) → Sensor -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → String -
toMap(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
covariant Sensor other) → bool -
The equality operator.
override
Static Methods
-
getSensorName(
int sensorType) → String -
getSensorString(
int sensorType) → String
Constants
- reportingModeContinuous → const int
- Events are reported at a constant rate which is set by the rate parameter of {@link SensorManager#registerListener(SensorEventListener, Sensor, int)}. Note: If other applications are requesting a higher rate, the sensor data might be delivered at faster rates than requested.
- reportingModeOnChange → const int
- Events are reported only when the value changes. Event delivery rate can be limited by setting appropriate value for rate parameter of {@link SensorManager#registerListener(SensorEventListener, Sensor, int)} Note: If other applications are requesting a higher rate, the sensor data might be delivered at faster rates than requested.
- reportingModeOneShot → const int
- Events are reported in one-shot mode. Upon detection of an event, the sensor deactivates itself and then sends a single event. Sensors of this reporting mode must be registered to using {@link SensorManager#requestTriggerSensor(TriggerEventListener, Sensor)}.
- reportingModeSpecialTrigger → const int
- Events are reported as described in the description of the sensor. The rate passed to registerListener might not have an impact on the rate of event delivery. See the sensor definition for more information on when and how frequently the events are reported. For example, step detectors report events when a step is detected.
- sensorStringTypeTiltDetector → const String
- A constant string describing a wake up tilt detector sensor type.
-
sSensorReportingModes
→ const List<
int> - Holds the reporting mode and maximum length of the values array associated with {@link SensorEvent} or {@link TriggerEvent} for the Sensor
- stringTypeAccelerometer → const String
- A constant string describing an accelerometer sensor type.
- stringTypeAccelerometerUncalibrated → const String
- A constant string describing an uncalibrated accelerometer sensor.
- stringTypeAmbientTemperature → const String
- A constant string describing an ambient temperature sensor type.
- stringTypeDeviceOrientation → const String
- A constant string describing a device orientation sensor type.
- stringTypeGameRotationVector → const String
- A constant string describing an uncalibrated rotation vector sensor type.
- stringTypeGeomagneticRotationVector → const String
- A constant string describing a geo-magnetic rotation vector.
- stringTypeGlanceGesture → const String
- A constant string describing a wake gesture sensor.
- stringTypeGravity → const String
- A constant string describing a gravity sensor type.
- stringTypeGyroscope → const String
- A constant string describing a gyroscope sensor type.
- stringTypeGyroscopeUncalibrated → const String
- A constant string describing an uncalibrated gyroscope sensor type.
- stringTypeHeartBeat → const String
- A constant string describing a heart beat sensor.
- stringTypeHeartRate → const String
- A constant string describing a heart rate monitor.
- stringTypeHingeAngle → const String
- A constant string describing a hinge angle sensor.
- stringTypeLight → const String
- A constant string describing a light sensor type.
- stringTypeLinearAcceleration → const String
- A constant string describing a linear acceleration sensor type.
- stringTypeLowLatencyOffbodyDetect → const String
- A constant string describing a low-latency offbody detector sensor.
- stringTypeMagneticField → const String
- A constant string describing a magnetic field sensor type.
- stringTypeMagneticFieldUncalibrated → const String
- A constant string describing an uncalibrated magnetic field sensor type.
- stringTypeMotionDetect → const String
- A constant string describing a motion detection sensor.
- stringTypeOrientation → const String
- A constant string describing an orientation sensor type.
- stringTypePickUpGesture → const String
- A constant string describing a pick up sensor.
- stringTypePose6dof → const String
- A constant string describing a pose sensor with 6 degrees of freedom.
- stringTypePressure → const String
- A constant string describing a pressure sensor type.
- stringTypeProximity → const String
- A constant string describing a proximity sensor type.
- stringTypeRelativeHumidity → const String
- A constant string describing a relative humidity sensor type
- stringTypeRotationVector → const String
- A constant string describing a rotation vector sensor type.
- stringTypeSignificantMotion → const String
- A constant string describing a significant motion trigger sensor.
- stringTypeStationaryDetect → const String
- A constant string describing a stationary detection sensor.
- stringTypeStepCounter → const String
- A constant string describing a step counter sensor.
- stringTypeStepDetector → const String
- A constant string describing a step detector sensor.
- stringTypeTemperature → const String
- A constant string describing a temperature sensor type
- stringTypeWakeGesture → const String
- A constant string describing a wake gesture sensor.
- typeAccelerometer → const int
- A constant describing an accelerometer sensor type.
- typeAccelerometerUncalibrated → const int
- A constant describing an uncalibrated accelerometer sensor.
- typeAll → const int
- A constant describing all sensor types.
- typeAmbientTemperature → const int
- A constant describing an ambient temperature sensor type.
- typeDeviceOrientation → const int
- A constant describing a wrist tilt gesture sensor.
- typeGameRotationVector → const int
- A constant describing an uncalibrated rotation vector sensor type.
- typeGeomagneticRotationVector → const int
- A constant describing a geo-magnetic rotation vector.
- typeGlanceGesture → const int
- A constant describing a wake gesture sensor.
- typeGravity → const int
- A constant describing a gravity sensor type.
- typeGyroscope → const int
- A constant describing a gyroscope sensor type.
- typeGyroscopeUncalibrated → const int
- A constant describing an uncalibrated gyroscope sensor type.
- typeHeartBeat → const int
- A constant describing a heart beat sensor.
- typeHeartRate → const int
- A constant describing a heart rate monitor.
- typeHingeAngle → const int
- A constant describing a hinge angle sensor.
- typeLight → const int
- A constant describing a light sensor type.
- typeLinearAcceleration → const int
- A constant describing a linear acceleration sensor type.
- typeLowLatencyOffbodyDetect → const int
- A constant describing a dynamic sensor meta event sensor.
- typeMagneticField → const int
- A constant describing a magnetic field sensor type.
- typeMagneticFieldUncalibrated → const int
- A constant describing an uncalibrated magnetic field sensor type.
- typeMotionDetect → const int
- A constant describing a motion detect sensor.
- typeOrientation → const int
- A constant describing an orientation sensor type.
- typePickUpGesture → const int
- A constant describing a pick up sensor.
- typePose6dof → const int
- A constant describing a pose sensor with 6 degrees of freedom.
- typePressure → const int
- A constant describing a pressure sensor type.
- typeProximity → const int
- A constant describing a proximity sensor type. This is a wake up sensor.
- typeRelativeHumidity → const int
- A constant describing a relative humidity sensor type.
- typeRotationVector → const int
- A constant describing a rotation vector sensor type.
- typeSignificantMotion → const int
- A constant describing a significant motion trigger sensor.
- typeStationaryDetect → const int
- A constant describing a stationary detect sensor.
- typeStepCounter → const int
- A constant describing a step counter sensor.
- typeStepDetector → const int
- A constant describing a step detector sensor.
- typeTemperature → const int
- A constant describing a temperature sensor type
- typeTiltDetector → const int
- A sensor of this type generates an event each time a tilt event is detected. A tilt event is generated if the direction of the 2-seconds window average gravity changed by at least 35 degrees since the activation of the sensor. It is a wake up sensor.
- typeWakeGesture → const int
- A constant describing a wake gesture sensor.