Sensors in Android

Source: Internet
Author: User

Types of sensors in Android: Sensor Type direction, acceleration table, light, magnetic field, closeness, temperature, etc. The fastest sampling rate, game, common, and user interface. When an application requests a specific sampling rate, it only prompts or recommends the sensor subsystem. The specified sampling rate is not guaranteed. High Accuracy, Low, Medium, and unreliable. The SensorListener interface is the center of the sensor application. It includes two required methods: The onSensorChanged (int sensor, float values []) method is called when the sensor value is changed. This method is only called by the sensor monitored by this application (for more information, see the following ). Parameters of this method include: an integer indicating the changed sensor; an array of floating-point values indicating the sensor data itself. Some sensors only provide one data value, while others provide three floating point values. The direction sensor and the acceleration table sensor both provide three data values. When the sensor's precision changes, the onAccuracyChanged (int sensor, int accuracy) method is called. Parameters include two integers: one representing the sensor and the other representing the new accurate value of the sensor. To interact with a sensor, the application must register to listen for activities related to one or more sensors. Register and use the registerListener method of the SensorManager class. The sample code in this article demonstrates how to register and deregister the SensorListener. The following are several sensors supported by Android: Sensor. TYPE_ACCELEROMETER: Accelerometer Sensor. TYPE_GYROSCOPE: gyroscope Sensor. TYPE_LIGHT: brightness Sensor. TYPE_MAGNETIC_FIELD: Geomagnetic Sensor. TYPE_ORIENTATION: Orientation Sensor. TYPE_PRESSURE: pressure Sensor. TYPE_PROXIMITY: short-range Sensor. TYPE_TEMPERATURE: Temperature Sensor previous article: Android Baidu map basic implementation (TAG + GPS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.