Sensor

Sensor Components

AccelerometerSensor

This component senses the Android device's accelerometer, which detects shaking and measures acceleration in three dimensions. Acceleration is measured in SI units (m/s 2 ). If the device is a rest lying flat on its back, the Z acceleration will be about 9.8.

The component produces three values.

Properties

Available
Indicates whether the accelerometer is present on the Android device.
Enabled
If set, accelerometer is enabled.
XAccel
Acceleration in the X-dimension.
YAccel
Acceleration in the Y-dimension.
ZAccel
Acceleration in the Z-dimension.
MinimumInterval
Minimum time interval between phone shakes. You may want to change the time interval depending on the activity you want to perform when the phone is shaken. For example, you may want the phone to say "Stop shaking me" each time the user shakes the phone. At shorter time intervals, this will produce an unwanted echo effect. In another case, you may want a quick flick of the phone to be considered a single shake and perhaps increment a counter each time the phone shakes. In cases such as this, a shorter time interval will be more appropriate to properly count the shakes.

Events

AccelerationChanged(number xAccel, number yAccel, number zAccel)
Called when the acceleration has changed.
Shaking()
Called repeatedly when the Android device is being shaken.

Methods

none

LocationSensor

This component provides the Android device's location, using GPS if available and an alternative method otherwise, such as cellular towers or known wireless networks.

LocationSensor is a non-visible component providing location information, including longitude, latitude, altitude (if supported by the device), and address. This component can also provide geocoding, converting a given address (not necessarily the current one) to a latitude (with the LatitudeFromAddress method) and a longitude (with the LongitudeFromAddress method).

In order to function, the component must have its Enabled property set to true, and the device must have location sensing enabled through either GPS satellites (if the device is outdoors) or an alternative method.

Properties

Accuracy
Indicates Android device accuracy level, in meters.
Altitude
Altitude of the Android device, if available.
AvailableProviders
List of available service providers, such as gps or network
CurrentAddress
Physical street address of the Android device.
DistanceInterval
Determines the minimum distance interval, in meters, that the sensor will try to use for sending out location updates. For example, if this is set to 5, then the sensor will fire a LocationChanged event only after 5 meters have been traversed. However, the sensor does not guarantee that an update will be received at exactly the distance interval. It may take more than 5 meters to fire an event, for instance.
Enabled
If set, location information is available.
HasAccuracy
If true, Android device can report its accuracy level.
HasAltitude
If true, Android device can report its altitude.
HasLongitudeLatitude
If true, Android device can report longitude and latitude.
Latitude
Android device latitude.
Longitude
Android device longitude.
ProviderLocked
The device will not change the service provider.
ProviderName
The current service provider.
TimeInterval
Determines the minimum time interval, in milliseconds, that the sensor will try to use for sending out location updates. However, location updates will only be received when the location of the phone actually changes, and use of the specified time interval is not guaranteed. For example, if 1000 is used as the time interval, location updates will never be fired sooner than 1000ms, but they may be fired anytime after.

Events

LocationChanged(number latitude, number longitude, number altitude)
Called when the Android device reports a new location.
StatusChanged(text provider, text status)
Called when the status of the service provider changes.

Methods

number LatitudeFromAddress(text locationName)
Determines the latitude of the given address.
number LongitudeFromAddress(text locationName)
Determines the longitude of the given address.
The location sensor currently gets results only for applications that have been packaged and downloaded to the phone.

OrientationSensor

Use an orientation sensor component to determine the phone's spatial orientation.

An orientation sensor is a non-visible component that reports the following three values, in degrees:

  • Roll: 0 degree when the device is level, increasing to 90 degrees as the device is tilted up onto its left side, and decreasing to ?90 degrees when the device is tilted up onto its right side.
  • Pitch: 0 degree when the device is level, increasing to 90 degrees as the device is tilted so its top is pointing down, then decreasing to 0 degree as it gets turned over. Similarly, as the device is tilted so its bottom points down, pitch decreases to ?90 degrees, then increases to 0 degree as it gets turned all the way over.
  • Azimuth: 0 degree when the top of the device is pointing north, 90 degrees when it is pointing east, 180 degrees when it is pointing south, 270 degrees when it is pointing west, etc.

These measurements assume that the device itself is not moving.

Properties

Available
Indicates whether the orientation sensor is present on the Android device.
Enabled
If set, the orientation sensor is enabled.
Azimuth
Returns the azimuth angle of the device.
Pitch
Returns the pitch angle of the device.
Roll
Returns the roll angle of the device.
Magnitude
Returns a number between 0 and 1 that indicates how much the device is tilted. It gives the magnitude of the force that would be felt by a ball rolling on the surface of the device.
Angle
Returns an angle that tells the direction in which the device is tiled. That is, it tells the direction of the force that would be felt by a ball rolling on the surface of the device.

Events

OrientationChanged(number azimuth, number pitch, number roll)
Called when the orientation has changed.

Methods

none