Android Sensors API

  1. Home
  2. Docs
  3. Android Sensors API
  4. Quickstart

Quickstart

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:

  • Accelerometer
  • Ambient temperature
  • Gravity
  • Gyroscope
  • Light
  • Linear acceleration
  • Magnetic field
  • Orientation
  • Pressure
  • Proximity
  • Relative humidity
  • Rotation vector
  • Temperature
  • Heart beat

The availability and the accuracy of each sensor depends on the device.

Was this article helpful to you? Yes No

How can we help?