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/s2). If the device is a rest lying flat on its back, the Z acceleration will be about 9.8.
The component produces three values.
-
XAccel
: Positive when the device is tilted to the right (that is, its left side is raised), and negative when the device is tilted to the left (its right size is raised). -
YAccel
: Positive when its bottom is raised, and negative when its top is raised. -
ZAccel
: Positive when the display is facing up, and negative when the display is facing down.
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.
Events
-
AccelerationChanged(number xAccel, number yAccel, number zAccel)
- Called when the acceleration has changed.
-
Shaking()
- Called repeatedly when the Android device is being shaken.
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.
-
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.
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
-
LatitudeFromAddress(text locationName)
- Determines the latitude of the given address.
-
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 degrees 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 degrees when the device is level, increasing to 90 degrees as the device is tilted so its top is pointing down, further increasing to 180 degrees as it gets turned over. Similarly, as the device is tilted so its bottom points down, pitch decreases to −90 degrees, then down to −180 degrees as it gets turned all the way over.
- Azimuth: 0 degrees 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.
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.