简体   繁体   中英

How does Android's proximity sensor work?

I'm reading the Android API and I see this

The proximity sensor lets you determine how far away an object is from a device. The following code shows you how to get an instance of the default proximity sensor

The proximity sensor is usually used to determine how far away a person's head is from the face of a handset device (for example, when a user is making or receiving a phone call). Most proximity sensors return the absolute distance, in cm, but some return only near and far values. The following code shows you how to use the proximity sensor:

Key statements being "usually used" and the general use of the term "object".

Can I specify that the object should be an apple on a tree in front of me? This documentation doesn't really give me any idea how the proximity position sensor works. Or is the sensor a chip inserted on an external object that android can pick up?

I expect it just emits an IR beam and measures how much light bounces back. See http://thecodeartist.blogspot.com/2011/01/proximity-sensor-on-android-gingerbread.html?m=1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM