Using the Android Sensors API plugin is pretty straightforward.
First, ensure that the plugin is activated (in Plugins). Once, it’s activated you will have access to all the functions of the Android Sensors API plugin.
All of these functions work the same way:
- First, you initialize the desired sensor with a call to a InitializeXXX function (XXX being the chosen sensor); the Android device will start receiving updates from this sensor. If the device doesn’t own the chosen sensor, the initialization method will return false.
- Second, you read values using a GetLastXXXMeasure function (e.g. GetLastAmbientTemperatureMeasure for the temperature sensor).
Internally, the measures are buffered (one buffer per sensor). Every time a new value is read from the sensor, the buffer is updated. The GetLastXXXMeasure methods are used to get the values of these buffers. So, technically, a call to GetLastXXXMeasure will always return the last measure provided by the chosen sensor.
At this time, the supported sensors are:
- Ambient temperature
- Linear acceleration
- Magnetic field
- Relative humidity
- Rotation vector
- Heart rate
The availability and the accuracy of each sensor depends on the device.