简体   繁体   English

Android的接近传感器如何工作?

[英]How does Android's proximity sensor work?

I'm reading the Android API and I see this 我正在阅读Android API ,看到了这个

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? 还是传感器是插入到Android可以拾取的外部对象上的芯片?

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 看到http://thecodeartist.blogspot.com/2011/01/proximity-sensor-on-android-gingerbread.html?m=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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