3. Sensor: location sensor

Source: Internet
Author: User
Tags ranges
Location sensor Overview

The Android platform provides two sensors to determine the location of the device. These two sensors are magnetic field sensors and direction sensors. The Android platform also provides a sensor (proximity sensor) that measures the distance from the front of a device to a neighboring object ). Magnetic field sensors and adjacent sensors are hardware-based sensors. Most Android phones and tablets have magnetic sensors. Adjacent sensors are usually common in mobile phones. This sensor can be used to test how far the screen is from the face when the phone is answered. You can complete some work when answering the call close to your ears. The direction sensor is based on software. The returned data of the sensor comes from the acceleration sensor and the magnetic field sensor.

Role of location sensor

Location Sensors are useful for determining the physical location of a device in the real world. For example, you can combine a magnetic field sensor and an accelerometer to measure the position of the device relative to the geomagnetic Arctic. You can also use a direction sensor to determine the position of the current device relative to its own reference system.

Both the magnetic field sensor and the direction sensor return three values (sensorevent. values), while the adjacent sensor returns only one value.

Direction Sensor

Sensorevent. Values [0]:

The angle of rotation around the Z axis. If the Y axis (normally in the direction of the mobile phone) is facing the north, the value is 0. If the Y axis points to the south, the value is 180, and the Y axis points to the east. The value is 90, if the Y axis points to the west, the value is 270.

Sensorevent. Values [1]:

Degrees that rotate around the X axis. When the orientation from the positive side of the Z axis to the positive side of the Y axis, the value is positive. Otherwise, it is a negative value. The value ranges from 180 to-180.

Sensorevent. Values [2]:

Degrees that rotate around the Y axis. If the direction is from the positive side of the Z axis to the positive side of the X axis, the value is positive. Otherwise, it is a negative value. The value ranges from 180 to-180.

Magnetic Field Sensor

Sensorevent. Values [0]:

Magnetic Force along the X axis (μT, millitesla)

Sensorevent. Values [1]:

Magnetic forces along the Y axis (μ T, millitesla)

Sensorevent. Values [2]:

Magnetic forces along the Y axis (μ T, millitesla)

Adjacent Sensor

 

Sensorevent. Values [0]:

 

Distance from the front of the mobile phone to the physical proximity (cm)

 

 Demo

 

 

 

 

 

 

 

 

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.