Sensor
public
final
class
Sensor
extends Object
java.lang.Object | |
↳ | android.hardware.Sensor |
Class representing a sensor. Use SensorManager.getSensorList
to get
the list of available sensors. For more information about Android sensors,
read the
Motion Sensors guide.
Summary
Constants | |
---|---|
int |
REPORTING_MODE_CONTINUOUS
Events are reported at a constant rate which is set by the rate parameter of
|
int |
REPORTING_MODE_ONE_SHOT
Events are reported in one-shot mode. |
int |
REPORTING_MODE_ON_CHANGE
Events are reported only when the value changes. |
int |
REPORTING_MODE_SPECIAL_TRIGGER
Events are reported as described in the description of the sensor. |
String |
STRING_TYPE_ACCELEROMETER
A constant string describing an accelerometer sensor type. |
String |
STRING_TYPE_ACCELEROMETER_LIMITED_AXES
A constant string describing a limited axes accelerometer sensor. |
String |
STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
A constant string describing an uncalibrated limited axes accelerometer sensor. |
String |
STRING_TYPE_ACCELEROMETER_UNCALIBRATED
A constant string describing an uncalibrated accelerometer sensor. |
String |
STRING_TYPE_AMBIENT_TEMPERATURE
A constant string describing an ambient temperature sensor type. |
String |
STRING_TYPE_GAME_ROTATION_VECTOR
A constant string describing an uncalibrated rotation vector sensor type. |
String |
STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR
A constant string describing a geo-magnetic rotation vector. |
String |
STRING_TYPE_GRAVITY
A constant string describing a gravity sensor type. |
String |
STRING_TYPE_GYROSCOPE
A constant string describing a gyroscope sensor type. |
String |
STRING_TYPE_GYROSCOPE_LIMITED_AXES
A constant string describing a limited axes gyroscope sensor. |
String |
STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
A constant string describing an uncalibrated limited axes gyroscope sensor. |
String |
STRING_TYPE_GYROSCOPE_UNCALIBRATED
A constant string describing an uncalibrated gyroscope sensor type. |
String |
STRING_TYPE_HEADING
A constant string describing a heading sensor. |
String |
STRING_TYPE_HEAD_TRACKER
A constant string describing a head tracker sensor. |
String |
STRING_TYPE_HEART_BEAT
A constant string describing a heart beat sensor. |
String |
STRING_TYPE_HEART_RATE
A constant string describing a heart rate monitor. |
String |
STRING_TYPE_HINGE_ANGLE
A constant string describing a hinge angle sensor. |
String |
STRING_TYPE_LIGHT
A constant string describing a light sensor type. |
String |
STRING_TYPE_LINEAR_ACCELERATION
A constant string describing a linear acceleration sensor type. |
String |
STRING_TYPE_LOW_LATENCY_OFFBODY_DETECT
A constant string describing a low-latency offbody detector sensor. |
String |
STRING_TYPE_MAGNETIC_FIELD
A constant string describing a magnetic field sensor type. |
String |
STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED
A constant string describing an uncalibrated magnetic field sensor type. |
String |
STRING_TYPE_MOTION_DETECT
A constant string describing a motion detection sensor. |
String |
STRING_TYPE_ORIENTATION
This constant was deprecated
in API level 20.
use |
String |
STRING_TYPE_POSE_6DOF
A constant string describing a pose sensor with 6 degrees of freedom. |
String |
STRING_TYPE_PRESSURE
A constant string describing a pressure sensor type. |
String |
STRING_TYPE_PROXIMITY
A constant string describing a proximity sensor type. |
String |
STRING_TYPE_RELATIVE_HUMIDITY
A constant string describing a relative humidity sensor type |
String |
STRING_TYPE_ROTATION_VECTOR
A constant string describing a rotation vector sensor type. |
String |
STRING_TYPE_SIGNIFICANT_MOTION
A constant string describing a significant motion trigger sensor. |
String |
STRING_TYPE_STATIONARY_DETECT
A constant string describing a stationary detection sensor. |
String |
STRING_TYPE_STEP_COUNTER
A constant string describing a step counter sensor. |
String |
STRING_TYPE_STEP_DETECTOR
A constant string describing a step detector sensor. |
String |
STRING_TYPE_TEMPERATURE
This constant was deprecated
in API level 20.
use
|
int |
TYPE_ACCELEROMETER
A constant describing an accelerometer sensor type. |
int |
TYPE_ACCELEROMETER_LIMITED_AXES
A constant describing a limited axes accelerometer sensor. |
int |
TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
A constant describing an uncalibrated limited axes accelerometer sensor. |
int |
TYPE_ACCELEROMETER_UNCALIBRATED
A constant describing an uncalibrated accelerometer sensor. |
int |
TYPE_ALL
A constant describing all sensor types. |
int |
TYPE_AMBIENT_TEMPERATURE
A constant describing an ambient temperature sensor type. |
int |
TYPE_DEVICE_PRIVATE_BASE
The lowest sensor type vendor defined sensors can use. |
int |
TYPE_GAME_ROTATION_VECTOR
A constant describing an uncalibrated rotation vector sensor type. |
int |
TYPE_GEOMAGNETIC_ROTATION_VECTOR
A constant describing a geo-magnetic rotation vector. |
int |
TYPE_GRAVITY
A constant describing a gravity sensor type. |
int |
TYPE_GYROSCOPE
A constant describing a gyroscope sensor type. |
int |
TYPE_GYROSCOPE_LIMITED_AXES
A constant describing a limited axes gyroscope sensor. |
int |
TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
A constant describing an uncalibrated limited axes gyroscope sensor. |
int |
TYPE_GYROSCOPE_UNCALIBRATED
A constant describing an uncalibrated gyroscope sensor type. |
int |
TYPE_HEADING
A constant string describing a heading sensor. |
int |
TYPE_HEAD_TRACKER
A constant describing a head tracker sensor. |
int |
TYPE_HEART_BEAT
A constant describing a heart beat sensor. |
int |
TYPE_HEART_RATE
A constant describing a heart rate monitor. |
int |
TYPE_HINGE_ANGLE
A constant describing a hinge angle sensor. |
int |
TYPE_LIGHT
A constant describing a light sensor type. |
int |
TYPE_LINEAR_ACCELERATION
A constant describing a linear acceleration sensor type. |
int |
TYPE_LOW_LATENCY_OFFBODY_DETECT
A constant describing a low latency off-body detect sensor. |
int |
TYPE_MAGNETIC_FIELD
A constant describing a magnetic field sensor type. |
int |
TYPE_MAGNETIC_FIELD_UNCALIBRATED
A constant describing an uncalibrated magnetic field sensor type. |
int |
TYPE_MOTION_DETECT
A constant describing a motion detect sensor. |
int |
TYPE_ORIENTATION
This constant was deprecated
in API level 15.
use |
int |
TYPE_POSE_6DOF
A constant describing a pose sensor with 6 degrees of freedom. |
int |
TYPE_PRESSURE
A constant describing a pressure sensor type. |
int |
TYPE_PROXIMITY
A constant describing a proximity sensor type. |
int |
TYPE_RELATIVE_HUMIDITY
A constant describing a relative humidity sensor type. |
int |
TYPE_ROTATION_VECTOR
A constant describing a rotation vector sensor type. |
int |
TYPE_SIGNIFICANT_MOTION
A constant describing a significant motion trigger sensor. |
int |
TYPE_STATIONARY_DETECT
A constant describing a stationary detect sensor. |
int |
TYPE_STEP_COUNTER
A constant describing a step counter sensor. |
int |
TYPE_STEP_DETECTOR
A constant describing a step detector sensor. |
int |
TYPE_TEMPERATURE
This constant was deprecated
in API level 15.
use
|
Public methods | |
---|---|
int
|
getFifoMaxEventCount()
|
int
|
getFifoReservedEventCount()
|
int
|
getHighestDirectReportRateLevel()
Get the highest supported direct report mode rate level of the sensor. |
int
|
getId()
|
int
|
getMaxDelay()
This value is defined only for continuous and on-change sensors. |
float
|
getMaximumRange()
|
int
|
getMinDelay()
|
String
|
getName()
|
float
|
getPower()
|
int
|
getReportingMode()
Each sensor has exactly one reporting mode associated with it. |
float
|
getResolution()
|
String
|
getStringType()
|
int
|
getType()
|
String
|
getVendor()
|
int
|
getVersion()
|
boolean
|
isAdditionalInfoSupported()
Returns true if the sensor supports sensor additional information API |
boolean
|
isDirectChannelTypeSupported(int sharedMemType)
Test if a sensor supports a specified direct channel type. |
boolean
|
isDynamicSensor()
Returns true if the sensor is a dynamic sensor. |
boolean
|
isWakeUpSensor()
Returns true if the sensor is a wake-up sensor. |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
---|---|
Constants
REPORTING_MODE_CONTINUOUS
public static final int REPORTING_MODE_CONTINUOUS
Events are reported at a constant rate which is set by the rate parameter of
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.
Constant Value: 0 (0x00000000)
REPORTING_MODE_ONE_SHOT
public static final int REPORTING_MODE_ONE_SHOT
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 SensorManager.requestTriggerSensor(TriggerEventListener, Sensor)
.
Constant Value: 2 (0x00000002)
REPORTING_MODE_ON_CHANGE
public static final int REPORTING_MODE_ON_CHANGE
Events are reported only when the value changes. Event delivery rate can be limited by
setting appropriate value for rate parameter of
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.
Constant Value: 1 (0x00000001)
REPORTING_MODE_SPECIAL_TRIGGER
public static final int REPORTING_MODE_SPECIAL_TRIGGER
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.
Constant Value: 3 (0x00000003)
STRING_TYPE_ACCELEROMETER
public static final String STRING_TYPE_ACCELEROMETER
A constant string describing an accelerometer sensor type.
See also:
Constant Value: "android.sensor.accelerometer"
STRING_TYPE_ACCELEROMETER_LIMITED_AXES
public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES
A constant string describing a limited axes accelerometer sensor.
See also:
Constant Value: "android.sensor.accelerometer_limited_axes"
STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
public static final String STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
A constant string describing an uncalibrated limited axes accelerometer sensor.
Constant Value: "android.sensor.accelerometer_limited_axes_uncalibrated"
STRING_TYPE_ACCELEROMETER_UNCALIBRATED
public static final String STRING_TYPE_ACCELEROMETER_UNCALIBRATED
A constant string describing an uncalibrated accelerometer sensor.
See also:
Constant Value: "android.sensor.accelerometer_uncalibrated"
STRING_TYPE_AMBIENT_TEMPERATURE
public static final String STRING_TYPE_AMBIENT_TEMPERATURE
A constant string describing an ambient temperature sensor type.
See also:
Constant Value: "android.sensor.ambient_temperature"
STRING_TYPE_GAME_ROTATION_VECTOR
public static final String STRING_TYPE_GAME_ROTATION_VECTOR
A constant string describing an uncalibrated rotation vector sensor type.
See also:
Constant Value: "android.sensor.game_rotation_vector"
STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR
public static final String STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR
A constant string describing a geo-magnetic rotation vector.
See also:
Constant Value: "android.sensor.geomagnetic_rotation_vector"
STRING_TYPE_GRAVITY
public static final String STRING_TYPE_GRAVITY
A constant string describing a gravity sensor type.
See also:
Constant Value: "android.sensor.gravity"
STRING_TYPE_GYROSCOPE
public static final String STRING_TYPE_GYROSCOPE
A constant string describing a gyroscope sensor type.
See also:
Constant Value: "android.sensor.gyroscope"
STRING_TYPE_GYROSCOPE_LIMITED_AXES
public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES
A constant string describing a limited axes gyroscope sensor.
See also:
Constant Value: "android.sensor.gyroscope_limited_axes"
STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
public static final String STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
A constant string describing an uncalibrated limited axes gyroscope sensor.
See also:
Constant Value: "android.sensor.gyroscope_limited_axes_uncalibrated"
STRING_TYPE_GYROSCOPE_UNCALIBRATED
public static final String STRING_TYPE_GYROSCOPE_UNCALIBRATED
A constant string describing an uncalibrated gyroscope sensor type.
See also:
Constant Value: "android.sensor.gyroscope_uncalibrated"
STRING_TYPE_HEADING
public static final String STRING_TYPE_HEADING
A constant string describing a heading sensor.
See also:
Constant Value: "android.sensor.heading"
STRING_TYPE_HEAD_TRACKER
public static final String STRING_TYPE_HEAD_TRACKER
A constant string describing a head tracker sensor. Note that this sensor type is typically
not available for apps to use.
See SensorEvent.values
for more details.
Constant Value: "android.sensor.head_tracker"
STRING_TYPE_HEART_BEAT
public static final String STRING_TYPE_HEART_BEAT
A constant string describing a heart beat sensor.
See also:
Constant Value: "android.sensor.heart_beat"
STRING_TYPE_HEART_RATE
public static final String STRING_TYPE_HEART_RATE
A constant string describing a heart rate monitor.
See also:
Constant Value: "android.sensor.heart_rate"
STRING_TYPE_HINGE_ANGLE
public static final String STRING_TYPE_HINGE_ANGLE
A constant string describing a hinge angle sensor.
See also:
Constant Value: "android.sensor.hinge_angle"
STRING_TYPE_LIGHT
public static final String STRING_TYPE_LIGHT
A constant string describing a light sensor type.
See also:
Constant Value: "android.sensor.light"
STRING_TYPE_LINEAR_ACCELERATION
public static final String STRING_TYPE_LINEAR_ACCELERATION
A constant string describing a linear acceleration sensor type.
See also:
Constant Value: "android.sensor.linear_acceleration"
STRING_TYPE_LOW_LATENCY_OFFBODY_DETECT
public static final String STRING_TYPE_LOW_LATENCY_OFFBODY_DETECT
A constant string describing a low-latency offbody detector sensor.
See also:
Constant Value: "android.sensor.low_latency_offbody_detect"
STRING_TYPE_MAGNETIC_FIELD
public static final String STRING_TYPE_MAGNETIC_FIELD
A constant string describing a magnetic field sensor type.
See also:
Constant Value: "android.sensor.magnetic_field"
STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED
public static final String STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED
A constant string describing an uncalibrated magnetic field sensor type.
See also:
Constant Value: "android.sensor.magnetic_field_uncalibrated"
STRING_TYPE_MOTION_DETECT
public static final String STRING_TYPE_MOTION_DETECT
A constant string describing a motion detection sensor.
See also:
Constant Value: "android.sensor.motion_detect"
STRING_TYPE_ORIENTATION
public static final String STRING_TYPE_ORIENTATION
This constant was deprecated
in API level 20.
use SensorManager.getOrientation()
instead.
A constant string describing an orientation sensor type.
See also:
Constant Value: "android.sensor.orientation"
STRING_TYPE_POSE_6DOF
public static final String STRING_TYPE_POSE_6DOF
A constant string describing a pose sensor with 6 degrees of freedom.
See also:
Constant Value: "android.sensor.pose_6dof"
STRING_TYPE_PRESSURE
public static final String STRING_TYPE_PRESSURE
A constant string describing a pressure sensor type.
See also:
Constant Value: "android.sensor.pressure"
STRING_TYPE_PROXIMITY
public static final String STRING_TYPE_PROXIMITY
A constant string describing a proximity sensor type.
See also:
Constant Value: "android.sensor.proximity"
STRING_TYPE_RELATIVE_HUMIDITY
public static final String STRING_TYPE_RELATIVE_HUMIDITY
A constant string describing a relative humidity sensor type
See also:
Constant Value: "android.sensor.relative_humidity"
STRING_TYPE_ROTATION_VECTOR
public static final String STRING_TYPE_ROTATION_VECTOR
A constant string describing a rotation vector sensor type.
See also:
Constant Value: "android.sensor.rotation_vector"
STRING_TYPE_SIGNIFICANT_MOTION
public static final String STRING_TYPE_SIGNIFICANT_MOTION
A constant string describing a significant motion trigger sensor.
See also:
Constant Value: "android.sensor.significant_motion"
STRING_TYPE_STATIONARY_DETECT
public static final String STRING_TYPE_STATIONARY_DETECT
A constant string describing a stationary detection sensor.
See also:
Constant Value: "android.sensor.stationary_detect"
STRING_TYPE_STEP_COUNTER
public static final String STRING_TYPE_STEP_COUNTER
A constant string describing a step counter sensor.
See also:
Constant Value: "android.sensor.step_counter"
STRING_TYPE_STEP_DETECTOR
public static final String STRING_TYPE_STEP_DETECTOR
A constant string describing a step detector sensor.
See also:
Constant Value: "android.sensor.step_detector"
STRING_TYPE_TEMPERATURE
public static final String STRING_TYPE_TEMPERATURE
This constant was deprecated
in API level 20.
use
Sensor.STRING_TYPE_AMBIENT_TEMPERATURE
instead.
A constant string describing a temperature sensor type
See also:
Constant Value: "android.sensor.temperature"
TYPE_ACCELEROMETER
public static final int TYPE_ACCELEROMETER
A constant describing an accelerometer sensor type.
See SensorEvent.values
for more details.
Constant Value: 1 (0x00000001)
TYPE_ACCELEROMETER_LIMITED_AXES
public static final int TYPE_ACCELEROMETER_LIMITED_AXES
A constant describing a limited axes accelerometer sensor.
See SensorEvent.values
for more details.
Constant Value: 38 (0x00000026)
TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
public static final int TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
A constant describing an uncalibrated limited axes accelerometer sensor.
See SensorEvent.values
for more details.
Constant Value: 40 (0x00000028)
TYPE_ACCELEROMETER_UNCALIBRATED
public static final int TYPE_ACCELEROMETER_UNCALIBRATED
A constant describing an uncalibrated accelerometer sensor.
See SensorEvent.values
for more details.
Constant Value: 35 (0x00000023)
TYPE_ALL
public static final int TYPE_ALL
A constant describing all sensor types.
Constant Value: -1 (0xffffffff)
TYPE_AMBIENT_TEMPERATURE
public static final int TYPE_AMBIENT_TEMPERATURE
A constant describing an ambient temperature sensor type.
See SensorEvent.values
for more details.
Constant Value: 13 (0x0000000d)
TYPE_DEVICE_PRIVATE_BASE
public static final int TYPE_DEVICE_PRIVATE_BASE
The lowest sensor type vendor defined sensors can use. All vendor sensor types are greater than or equal to this constant.
Constant Value: 65536 (0x00010000)
TYPE_GAME_ROTATION_VECTOR
public static final int TYPE_GAME_ROTATION_VECTOR
A constant describing an uncalibrated rotation vector sensor type.
Identical to TYPE_ROTATION_VECTOR
except that it doesn't
use the geomagnetic field. Therefore the Y axis doesn't
point north, but instead to some other reference, that reference is
allowed to drift by the same order of magnitude as the gyroscope
drift around the Z axis.
In the ideal case, a phone rotated and returning to the same real-world orientation should report the same game rotation vector (without using the earth's geomagnetic field). However, the orientation may drift somewhat over time.
See SensorEvent.values
for more
details.
Constant Value: 15 (0x0000000f)
TYPE_GEOMAGNETIC_ROTATION_VECTOR
public static final int TYPE_GEOMAGNETIC_ROTATION_VECTOR
A constant describing a geo-magnetic rotation vector.
Similar to TYPE_ROTATION_VECTOR
, but using a magnetometer instead of using a
gyroscope. This sensor uses lower power than the other rotation vectors, because it doesn't
use the gyroscope. However, it is more noisy and will work best outdoors.
See SensorEvent.values
for more details.
Constant Value: 20 (0x00000014)
TYPE_GRAVITY
public static final int TYPE_GRAVITY
A constant describing a gravity sensor type.
See SensorEvent.values
for more details.
Constant Value: 9 (0x00000009)
TYPE_GYROSCOPE
public static final int TYPE_GYROSCOPE
A constant describing a gyroscope sensor type.
See SensorEvent.values
for more details.
Constant Value: 4 (0x00000004)
TYPE_GYROSCOPE_LIMITED_AXES
public static final int TYPE_GYROSCOPE_LIMITED_AXES
A constant describing a limited axes gyroscope sensor.
See SensorEvent.values
for more details.
Constant Value: 39 (0x00000027)
TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
public static final int TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
A constant describing an uncalibrated limited axes gyroscope sensor.
See SensorEvent.values
for more details.
Constant Value: 41 (0x00000029)
TYPE_GYROSCOPE_UNCALIBRATED
public static final int TYPE_GYROSCOPE_UNCALIBRATED
A constant describing an uncalibrated gyroscope sensor type.
Similar to TYPE_GYROSCOPE
but no gyro-drift compensation has been performed
to adjust the given sensor values. However, such gyro-drift bias values
are returned to you separately in the result SensorEvent.values
so you may use them for custom calibrations.
Factory calibration and temperature compensation is still applied to the rate of rotation (angular speeds).
See SensorEvent.values
for more
details.
Constant Value: 16 (0x00000010)
TYPE_HEADING
public static final int TYPE_HEADING
A constant string describing a heading sensor.
See SensorEvent.values
for more details.
Constant Value: 42 (0x0000002a)
TYPE_HEAD_TRACKER
public static final int TYPE_HEAD_TRACKER
A constant describing a head tracker sensor. Note that this sensor type is typically not
available for apps to use.
See SensorEvent.values
for more details.
Constant Value: 37 (0x00000025)
TYPE_HEART_BEAT
public static final int TYPE_HEART_BEAT
A constant describing a heart beat sensor.
See SensorEvent.values
for more details.
Constant Value: 31 (0x0000001f)
TYPE_HEART_RATE
public static final int TYPE_HEART_RATE
A constant describing a heart rate monitor.
The reported value is the heart rate in beats per minute.
The reported accuracy represents the status of the monitor during the reading. See the
SENSOR_STATUS_*
constants in SensorManager
for more details on accuracy/status values. In particular, when the accuracy is
SENSOR_STATUS_UNRELIABLE
or SENSOR_STATUS_NO_CONTACT
, the heart rate
value should be discarded.
This sensor requires permission android.permission.BODY_SENSORS
.
It will not be returned by SensorManager.getSensorsList
nor
SensorManager.getDefaultSensor
if the application doesn't have this permission.
Constant Value: 21 (0x00000015)
TYPE_HINGE_ANGLE
public static final int TYPE_HINGE_ANGLE
A constant describing a hinge angle sensor.
See SensorEvent.values
for more details.
Constant Value: 36 (0x00000024)
TYPE_LIGHT
public static final int TYPE_LIGHT
A constant describing a light sensor type.
See SensorEvent.values
for more details.
Constant Value: 5 (0x00000005)
TYPE_LINEAR_ACCELERATION
public static final int TYPE_LINEAR_ACCELERATION
A constant describing a linear acceleration sensor type.
See SensorEvent.values
for more details.
Constant Value: 10 (0x0000000a)
TYPE_LOW_LATENCY_OFFBODY_DETECT
public static final int TYPE_LOW_LATENCY_OFFBODY_DETECT
A constant describing a low latency off-body detect sensor.
See SensorEvent.values
for more details.
Constant Value: 34 (0x00000022)
TYPE_MAGNETIC_FIELD
public static final int TYPE_MAGNETIC_FIELD
A constant describing a magnetic field sensor type.
See SensorEvent.values
for more details.
Constant Value: 2 (0x00000002)
TYPE_MAGNETIC_FIELD_UNCALIBRATED
public static final int TYPE_MAGNETIC_FIELD_UNCALIBRATED
A constant describing an uncalibrated magnetic field sensor type.
Similar to TYPE_MAGNETIC_FIELD
but the hard iron calibration (device calibration
due to distortions that arise from magnetized iron, steel or permanent magnets on the
device) is not considered in the given sensor values. However, such hard iron bias values
are returned to you separately in the result SensorEvent.values
so you may use them for custom calibrations.
Also, no periodic calibration is performed (i.e. there are no discontinuities in the data stream while using this sensor) and assumptions that the magnetic field is due to the Earth's poles is avoided, but factory calibration and temperature compensation have been performed.
See SensorEvent.values
for more
details.
Constant Value: 14 (0x0000000e)
TYPE_MOTION_DETECT
public static final int TYPE_MOTION_DETECT
A constant describing a motion detect sensor.
See SensorEvent.values
for more details.
Constant Value: 30 (0x0000001e)
TYPE_ORIENTATION
public static final int TYPE_ORIENTATION
This constant was deprecated
in API level 15.
use SensorManager.getOrientation()
instead.
A constant describing an orientation sensor type.
See SensorEvent.values
for more details.
Constant Value: 3 (0x00000003)
TYPE_POSE_6DOF
public static final int TYPE_POSE_6DOF
A constant describing a pose sensor with 6 degrees of freedom.
Similar to TYPE_ROTATION_VECTOR
, with additional delta
translation from an arbitrary reference point.
See SensorEvent.values
for more details.
Can use camera, depth sensor etc to compute output value.
This is expected to be a high power sensor and expected only to be
used when the screen is on.
Expected to be more accurate than the rotation vector alone.
Constant Value: 28 (0x0000001c)
TYPE_PRESSURE
public static final int TYPE_PRESSURE
A constant describing a pressure sensor type.
See SensorEvent.values
for more details.
Constant Value: 6 (0x00000006)
TYPE_PROXIMITY
public static final int TYPE_PROXIMITY
A constant describing a proximity sensor type. This is a wake up sensor.
See SensorEvent.values
for more details.
See also:
Constant Value: 8 (0x00000008)
TYPE_RELATIVE_HUMIDITY
public static final int TYPE_RELATIVE_HUMIDITY
A constant describing a relative humidity sensor type.
See SensorEvent.values
for more details.
Constant Value: 12 (0x0000000c)
TYPE_ROTATION_VECTOR
public static final int TYPE_ROTATION_VECTOR
A constant describing a rotation vector sensor type.
See SensorEvent.values
for more details.
Constant Value: 11 (0x0000000b)
TYPE_SIGNIFICANT_MOTION
public static final int TYPE_SIGNIFICANT_MOTION
A constant describing a significant motion trigger sensor.
It triggers when an event occurs and then automatically disables itself. The sensor continues to operate while the device is asleep and will automatically wake the device to notify when significant motion is detected. The application does not need to hold any wake locks for this sensor to trigger. This is a wake up sensor.
See TriggerEvent
for more details.
See also:
Constant Value: 17 (0x00000011)
TYPE_STATIONARY_DETECT
public static final int TYPE_STATIONARY_DETECT
A constant describing a stationary detect sensor.
See SensorEvent.values
for more details.
Constant Value: 29 (0x0000001d)
TYPE_STEP_COUNTER
public static final int TYPE_STEP_COUNTER
A constant describing a step counter sensor.
A sensor of this type returns the number of steps taken by the user since the last reboot
while activated. The value is returned as a float (with the fractional part set to zero) and
is reset to zero only on a system reboot. The timestamp of the event is set to the time when
the last step for that event was taken. This sensor is implemented in hardware and is
expected to be low power. If you want to continuously track the number of steps over a long
period of time, do NOT unregister for this sensor, so that it keeps counting steps in the
background even when the AP is in suspend mode and report the aggregate count when the AP
is awake. Application needs to stay registered for this sensor because step counter does not
count steps if it is not activated. This sensor is ideal for fitness tracking applications.
It is defined as an Sensor.REPORTING_MODE_ON_CHANGE
sensor.
This sensor requires permission android.permission.ACTIVITY_RECOGNITION
.
See SensorEvent.values
for more details.
Constant Value: 19 (0x00000013)
TYPE_STEP_DETECTOR
public static final int TYPE_STEP_DETECTOR
A constant describing a step detector sensor.
A sensor of this type triggers an event each time a step is taken by the user. The only
allowed value to return is 1.0 and an event is generated for each step. Like with any other
event, the timestamp indicates when the event (here the step) occurred, this corresponds to
when the foot hit the ground, generating a high variation in acceleration. This sensor is
only for detecting every individual step as soon as it is taken, for example to perform dead
reckoning. If you only need aggregate number of steps taken over a period of time, register
for TYPE_STEP_COUNTER
instead. It is defined as a
Sensor.REPORTING_MODE_SPECIAL_TRIGGER
sensor.
This sensor requires permission android.permission.ACTIVITY_RECOGNITION
.
See SensorEvent.values
for more details.
Constant Value: 18 (0x00000012)
TYPE_TEMPERATURE
public static final int TYPE_TEMPERATURE
This constant was deprecated
in API level 15.
use
Sensor.TYPE_AMBIENT_TEMPERATURE
instead.
A constant describing a temperature sensor type
Constant Value: 7 (0x00000007)
Public methods
getFifoMaxEventCount
public int getFifoMaxEventCount ()
Returns | |
---|---|
int |
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. |
getFifoReservedEventCount
public int getFifoReservedEventCount ()
Returns | |
---|---|
int |
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. |
getHighestDirectReportRateLevel
public int getHighestDirectReportRateLevel ()
Get the highest supported direct report mode rate level of the sensor.
Returns | |
---|---|
int |
Highest direct report rate level of this sensor. Note that if the app does not have
the Manifest.permission.HIGH_SAMPLING_RATE_SENSORS permission, the highest
direct report rate level is SensorDirectChannel.RATE_NORMAL . If the sensor
does not support direct report mode, this returns SensorDirectChannel.RATE_STOP .
Value is SensorDirectChannel.RATE_STOP , SensorDirectChannel.RATE_NORMAL , SensorDirectChannel.RATE_FAST , or SensorDirectChannel.RATE_VERY_FAST |
getId
public int getId ()
Returns | |
---|---|
int |
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. |
getMaxDelay
public int getMaxDelay ()
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.
Returns | |
---|---|
int |
The max delay for this sensor in microseconds. |
getMaximumRange
public float getMaximumRange ()
Returns | |
---|---|
float |
maximum range of the sensor in the sensor's unit. |
getMinDelay
public int getMinDelay ()
Returns | |
---|---|
int |
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
Manifest.permission.HIGH_SAMPLING_RATE_SENSORS permission, the
minimum delay is capped at 5000 microseconds (200 Hz). |
getName
public String getName ()
Returns | |
---|---|
String |
name string of the sensor. The name is guaranteed to be unique for a particular sensor type. |
getPower
public float getPower ()
Returns | |
---|---|
float |
the power in mA used by this sensor while in use |
getReportingMode
public int getReportingMode ()
Each sensor has exactly one reporting mode associated with it. This method returns the reporting mode constant for this sensor type.
Returns | |
---|---|
int |
Reporting mode for the input sensor, one of REPORTING_MODE_* constants. |
getResolution
public float getResolution ()
Returns | |
---|---|
float |
resolution of the sensor in the sensor's unit. |
getStringType
public String getStringType ()
Returns | |
---|---|
String |
The type of this sensor as a string. |
getVendor
public String getVendor ()
Returns | |
---|---|
String |
vendor string of this sensor. |
getVersion
public int getVersion ()
Returns | |
---|---|
int |
version of the sensor's module. |
isAdditionalInfoSupported
public boolean isAdditionalInfoSupported ()
Returns true if the sensor supports sensor additional information API
Returns | |
---|---|
boolean |
true if the sensor supports sensor additional information API |
See also:
isDirectChannelTypeSupported
public boolean isDirectChannelTypeSupported (int sharedMemType)
Test if a sensor supports a specified direct channel type.
Parameters | |
---|---|
sharedMemType |
int : type of shared memory used by direct channel.
Value is either 0 or a combination of SensorDirectChannel.TYPE_MEMORY_FILE , and SensorDirectChannel.TYPE_HARDWARE_BUFFER |
Returns | |
---|---|
boolean |
true if the specified shared memory type is supported. |
isDynamicSensor
public boolean isDynamicSensor ()
Returns true if the sensor is a dynamic sensor.
Returns | |
---|---|
boolean |
true if the sensor is a dynamic sensor (sensor added at runtime). |
See also:
isWakeUpSensor
public boolean isWakeUpSensor ()
Returns true if the sensor is a wake-up sensor.
Application Processor Power modes
Application Processor(AP), is the processor on which applications run. When no wake lock is held and the user is not interacting with the device, this processor can enter a \u201cSuspend\u201d mode, reducing the power consumption by 10 times or more.
Non-wake-up sensors
Non-wake-up sensors are sensors that do not wake the AP out of suspend to report data. While
the AP is in suspend mode, the sensors continue to function and generate events, which are
put in a hardware FIFO. The events in the FIFO are delivered to the application when the AP
wakes up. If the FIFO was too small to store all events generated while the AP was in
suspend mode, the older events are lost: the oldest data is dropped to accommodate the newer
data. In the extreme case where the FIFO is non-existent maxFifoEventCount() == 0
,
all events generated while the AP was in suspend mode are lost. Applications using
non-wake-up sensors should usually:
- Either unregister from the sensors when they do not need them, usually in the activity\u2019s
onPause
method. This is the most common case. - Or realize that the sensors are consuming some power while the AP is in suspend mode and that even then, some events might be lost.
Wake-up sensors
In opposition to non-wake-up sensors, wake-up sensors ensure that their data is delivered
independently of the state of the AP. While the AP is awake, the wake-up sensors behave
like non-wake-up-sensors. When the AP is asleep, wake-up sensors wake up the AP to deliver
events. That is, the AP will wake up and the sensor will deliver the events before the
maximum reporting latency is elapsed or the hardware FIFO gets full. See SensorManager.registerListener(android.hardware.SensorEventListener, android.hardware.Sensor, int, int)
for more details.
Returns | |
---|---|
boolean |
true if this is a wake-up sensor, false otherwise. |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |