Android environment sensor and android Sensor

Source: Internet
Author: User

Android environment sensor and android Sensor

Environment Sensor

The Android platform provides four sensors for detecting different external environments. We can use these sensors to detect the surroundings. For example, it can detect the humidity, light, air pressure, and temperature of the surrounding air. All four sensors are hardware-based sensors. In addition to light sensors, the other three sensors are rarely seen on Android devices. Therefore, if an environment sensor is used, check whether the sensor supported by the current Android device is detected in the best condition.

Most motion and position sensors return multiple values, while all environmental sensors return only one value (SensorEvent. values [0]). For example, the temperature sensor returns degrees Celsius (°C) and the pressure sensor returns the pressure strength (hPa ). In addition, the values returned by the Environment sensor seldom receive noise interference, and the motion and position sensors often need to eliminate the impact of noise. For example, an accelerometer must eliminate the influence of gravity on its return value.

TYPE_AMBIENT_TEMPERATURE: event. values [0] Unit: °C


TYPE_LIGHT: event. values [0] Unit: lx


TYPE_PRESSURE: event. values [0] Unit: hPa


TYPE_RELATIVE_HUMIDITY: event. values [0] Unit: RH (%)


// The strongest light intensity (it is estimated that only desert areas can reach this value)
Public static final float LIGHT_SUNLIGHT_MAX = 120000.0f;
// The intensity of direct sunlight when there is no cloud
Public static final float LIGHT_SUNLIGHT = 111080000f;
// There is sunlight, but the intensity of some light is offset by the clouds
Public static final float LIGHT_SHADE = 20000.0f;
// Light intensity in multiple clouds
Public static final float LIGHT_OVERCAST = writable F;
// The intensity of light when the sun just rises (Sunrise)
Public static final float LIGHT_SUNRISE = 400366f;
// The light intensity when there is no sun in cloudy and rainy days
Public static final float LIGHT_CLOUDY = 100366f;
// The light intensity when the moon is present at night
Public static final float LIGHT_FULLMOON = 0.25f;
// The light intensity when there is no moon at night (of course, there cannot be a street lamp, that is, a dark one)
Public static final float LIGHT_NO_MOON = 0.001f;


The specific code is similar to that of the motion sensor I wrote.

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.