Android sensor (I)

Source: Internet
Author: User

Sensor types:

1. Motion sensor

Acceleration sensors, gravity sensors, and gyroscope (mobile phone attitude judgment)

2. Position Sensor

Direction sensor and Magnetic Sensor

3. Environment Sensors

Temperature Sensor, pressure sensor, and brightness Sensor

 

Sensor usage:

1. Get the sensormanager object

Sensormanager = (sensormanager) getsystemservice (context. sensor_service );

2. Run the getdefasensensor () method of the sensormanager object to obtain the Sensor Object and pass in a specific parameter.

3. Get attributes of the Sensor Object

4. register the sensor using the sensormanager object, sensormanager. registerlistener (sensoreventlistener listener, sensor, int rate );

The third parameter is the acquisition frequency: sensor_delay_normal (200000 subtle) sensor_delay_ui (60000 subtle) sensor_delay_game (20000 subtle) sensor_delay_fastest (0 microsecond) usage principle: Try to use a lower sensor sampling rate. In this way, the system consumes less and saves power.

 

Related Article

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.