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.