Android common Sensor

Source: Internet
Author: User

Sensor Type:

Direction, acceleration (gravity), light, magnetic field, distance (closeness), temperature, etc.

(1), direction sensor: sensor. type_orientation

(2) g_sensor acceleration (gravity) sensor: sensor. type_accelerometer

(3) Rochelle sensor light sensor: sensor. type_light

(4) m_sensor Magnetic Field Sensor: sensor. type_magnetic_field

(5), p_sensor distance (proximity) sensor: sensor. type_proximity

(6) Temperature Sensor: sensor. type_temperature

ProgramApplication in:

// Obtain a sensor type

Sensor sensor = sensormanager. getdefasensensor (sensor. type_accelerometer );

// Register the listener to obtain the sensor change value

Sensormanager. registerlistener (listener, sensor, sensormanager. sensor_delay_game );

The third parameter above is the sampling rate: the fastest, game, normal, and user interface.

When an application requests a specific sampling rate, it is only a recommendation for the sensor subsystem, and the specific sampling rate is not guaranteed to be available.

Fastest: sensormanager. sensor_delay_fastest

The lowest latency is generally not recommended for processing especially sensitive data. This mode may cause a large amount of power consumption on mobile phones,AlgorithmPoor processing will affect the game logic and UI performance.

Game: sensormanager. sensor_delay_game

Game latency. This level is generally used in most real-time games.

Normal: sensormanager. sensor_delay_normal

Standard latency can be used for general games of the benefit or easy level, but a low sampling rate may cause frame skipping for some racing games.

User Interface: sensormanager. sensor_delay_ui

It is generally used for automatic screen rotation, which saves power and logic processing, but is not used in game development.

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.