Breaking News
Home / Android / Android FAQ / Android – Sensors a review

Android – Sensors a review

Android Sensors

Android devices comes with a variety of sensor built into the hardware the same sensors can be acessed via the Android SDK. Basically there are three types of sensors:

Android Sensors Types<!>

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

AvailableIndicates whether the accelerometer is present on the Android device.

EnabledIf set, accelerometer is enabled.

XAccelAcceleration in the X-dimension.

YAccelAcceleration in the Y-dimension.

ZAccelAcceleration 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

LocationSensorThis 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

AccuracyIndicates Android device accuracy level, in meters.AltitudeAltitude of the Android device, if available.

AvailableProvidersList of available service providers, such as gps or networkCurrentAddressPhysical street address of the Android device.

EnabledIf set, location information is available.HasAccuracyIf true, Android device can report its accuracy level.

HasAltitudeIf true, Android device can report its altitude.HasLongitudeLatitudeIf true, Android device can report longitude and latitude.

LatitudeAndroid device latitude.LongitudeAndroid device longitude.ProviderLockedThe 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.

These measurements assume that the device itself is not moving.

Properties

AvailableIndicates whether the orientation sensor is present on the Android device.

EnabledIf set, the orientation sensor is enabled.

AzimuthReturns the azimuth angle of the device.

PitchReturns the pitch angle of the device.RollReturns the roll angle of the device.

MagnitudeReturns 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.

AngleReturns 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.

[pb_builder]

Check Also

What’s new in Google Icecream Sandwich (Android 4.0)?

Code named Ice Cream Sandwich is the upcoming release of Android 4.0 For sure you …

Leave a Reply