Android sensor — detailed explanation and use of light sensor

Android devices have many sensors, one of which controls the brightness of your screen. When you use your phone in a dark place, the screen of your device will automatically dim to protect your eyes.

In this way, Android uses a light sensor to obtain the brightness change of your surrounding environment. The light sensor is usually on the top of the mobile phone.

To use this sensor in the program

(1) First, get the sensormanager sensor Manager Service: sensormanager sensormanager = (sensormanager) getsystemservice (context. Sensor_service);

(2) Get light sensor: sensor liaghtsensor = sensormanager getDefaultSensor(Sensor.TYPE_LIGHT)//Sensor. TYPE_ Light stands for light sensor

(3) Registering and monitoring light sensors:

A simple code to obtain the light intensity lux of the light sensor:

For some programs, the judgment of light sensor can be considered when changing the screen brightness of the current program.

Because most of these programs have such a problem, when the screen brightness is set to a value (in non automatic brightness adjustment mode), it is invalid to set it to automatic brightness adjustment mode.

The above is the data sorting of Android sensor light sensing. We will continue to supplement relevant data in the future. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>