From GPS or network location to accelerometer, gyroscope, temperature, barometer, and more, use the device's sensors to provide extensive location and motion features to your app.
Sensors that monitor motion, orientation, and different environmental variables are integrated into most Android-powered smartphones. These sensors may provide raw data with great precision and accuracy, making them helpful for monitoring three-dimensional device movement or location, as well as changes in the ambient environment around a device. A game may, for example, use data from a device's gravity sensor to infer sophisticated user gestures and actions like tilt, shaking, rotation, and swing.
The Android platform has a number of sensors that may be used to track a device's movement.
The sensor topologies that are feasible differ depending on the sensor type:
The geomagnetic field sensor and the accelerometer are two sensors included in the Android platform that may be used to detect a device's location. The Android platform also has a sensor for determining how near a device's face is to an item (known as the proximity sensor). The proximity sensor and the geomagnetic field sensor are both hardware-based sensors. A geomagnetic field sensor is included by most mobile and tablet makers. A proximity sensor is also commonly included by handset makers to detect when a device is held close to a user's face (for example, during a phone call). The information from the device's accelerometer and geomagnetic field sensor may be used to determine a device's orientation.
Four sensors are included with the Android platform, allowing you to monitor various environmental characteristics. These sensors may be used to measure relative ambient humidity, illuminance, ambient pressure, and ambient temperature in close proximity to an Android smartphone. All four environment sensors are hardware-based, and they can only be used if a device maker has included them in the design. Environment sensors are not always present on devices, with the exception of the light sensor, which is used by most device makers to adjust screen brightness. As a result, it's critical to double-check if an environment sensor exists at runtime before attempting to collect data from it.
|