Android programming uses light sensor to obtain light intensity [lightsensormanager encapsulation class]

This paper describes the method of using light sensor to obtain light intensity in Android programming. Share with you for your reference, as follows:

In Android development, sometimes we need to know the light intensity of the environment where the device is located. Of course, this requires our device to have a light sensor. Usually, the automatic brightness of the screen of our mobile phone is realized by light sensor. The sensor is near the front camera. In addition, there is a distance sensor. Here we mainly explain how to use the light sensor of Android phone.

The following is a light sensor management class I simply encapsulated, which mainly provides three methods:

1.start (): start, call before getting the intensity. 2.stop (): stop and call after no longer need to get the light intensity. 3. Getlux (): obtain the light intensity, in lux.

If you need additional methods, you can add them according to the returned light intensity. The following is the entire lightsensormanager class

For this value of light intensity. The darker the value, the lower the value. The lowest value should be 0. There are about 300 indoor in the daytime. It is only for reference. I don't know whether there will be some errors in different equipment.

The calling program will not be posted. You can directly see the data through the log. This class is used in my custom camera to automatically adjust the exposure level, and the effect is still there.

More readers interested in Android related content can view the special topics of this site: introduction and advanced tutorial of Android development, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android operation skills of SQLite database, summary of Android operation skills of JSON format data, summary of Android resource operation skills, and Android control usage summary

I hope this article will help you in Android programming.

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
分享
二维码
< <上一篇
下一篇>>