A proximity sensor is an infrared sensor that detects the presence of an object in front of a smartphone screen without physical contact. Its main function is to turn off the display during a phone call to prevent accidental cheek touches and save battery life. According to the Google Android Developer Guide, 2024, modern proximity sensors measure distances from 0 to 10 cm with 0.5 cm accuracy and a response time of less than 50 ms.
Key Takeaways
Proximity sensor — a contactless infrared sensor located at the top of the smartphone’s front panel, next to the earpiece speaker. It consists of an infrared LED (IR LED) and a photodetector (photodiode or phototransistor). The first mass-market smartphone with a proximity sensor was the Apple iPhone (2007) — since then, the sensor has become a mandatory component in all modern phones.
The sensor is usually hidden under the display glass and is only visible from a certain angle as a small dot. Modern models use an optical module with a narrow beam angle (15–30 degrees) to prevent false triggers from glass reflections. Manufacturers include Sharp, ams OSRAM (TMD series), Silicon Labs, and their contract partners.
| Parameter | Value |
|---|---|
| Wavelength | 850–940 nm (invisible IR range) |
| Range | 0–10 cm |
| Resolution | 0.5 cm |
| Power Consumption | 0.3–0.7 mA |
| Response Time | 10–50 ms |
Mobile devices use discrete sensors (a separate chip with IR LED + photodiode) and integrated modules (both elements on a single chip). Integrated solutions (ams TMD2635, size 1×1×0.5 mm) are used in ultra-thin chassis of modern flagships and take up minimal board space.
The operating principle of a proximity sensor is based on measuring the intensity of reflected IR radiation. The infrared LED emits a light pulse (850–940 nm), and the photodiode measures the amount of light reflected from an object. If the reflected signal exceeds a threshold, the object is considered near (less than 3–5 cm).
The main technical challenge is solar interference and noise from other IR sources. The solution is emission modulation: the IR LED emits pulses at 10–100 kHz, and the photodetector synchronously detects the signal, filtering out the DC component. According to ams Application Note AN000610 (2024), synchronous detection suppresses background illumination by 40–60 dB.
The trigger threshold is set by the manufacturer during calibration and depends on the display glass transparency. A typical threshold corresponds to a reflection distance of 2–4 cm. When a finger or ear is placed closer than the threshold, the sensor outputs 0 (near); otherwise, it returns the maximum range value (8–10 cm depending on the model).
IR proximity sensor measures reflection intensity — a binary sensor with two states. Time-of-Flight (ToF) measures the time light takes to travel to an object and back, allowing precise distance measurement up to several meters. In mobile devices, ToF sensors (VL53L5 from STMicroelectronics) are used for camera autofocus and AR applications.
For the task of turning off the screen during a call, a simple binary IR sensor is sufficient — its cost is $0.10–$0.30 compared to $1–$3 for a ToF module. A ToF sensor adds precise distance measurement but is overkill for the basic task. Some flagships (Samsung Galaxy S23 Ultra) use combined modules that integrate both technologies.
| Parameter | IR Proximity | ToF Sensor |
|---|---|---|
| Principle | Reflection intensity | Light time-of-flight |
| Range | 0–10 cm | 0–400 cm |
| Accuracy | 0.5 cm | 0.1 cm |
| Cost | $0.10–$0.30 | $1–$3 |
| Application | Screen during calls | Autofocus, AR |
Android provides access to the proximity sensor through Sensor.TYPE_PROXIMITY. A key feature of the API is that the sensor returns only two practically meaningful values: 0 (object near) and the maximum range value (usually 5–10 cm) when no object is present. Internal algorithms hide the analog nature of the signal.
The binary nature of the sensor means the app cannot get the exact distance to an object — only whether an obstacle is present or absent within the sensing zone. This is a hardware limitation. For more precise measurements, use a ToF sensor (if available) through the standard TYPE_PROXIMITY API, but on devices with ToF it returns analog values.
val proximitySensor = sensorManager
.getDefaultSensor(Sensor.TYPE_PROXIMITY)
sensorManager.registerListener(
object : SensorEventListener {
override fun onSensorChanged(event: SensorEvent) {
val distance = event.values[0]
val maxRange = proximitySensor?.maximumRange ?: 10f
when {
distance < maxRange -> lockScreen()
else -> unlockScreen()
}
}
override fun onAccuracyChanged(
sensor: Sensor, accuracy: Int
) {}
},
proximitySensor,
SensorManager.SENSOR_DELAY_UI
)
When registering the proximity sensor, it is important to use SCREEN_OFF_WAKE_LOCK if the app needs to keep running with the screen off (e.g., call recording). Without a Wake Lock, the CPU may enter sleep mode and stop receiving sensor data. The SENSOR_DELAY_UI flag (200 ms) is sufficient for most scenarios.
Although the sensor’s primary function is turning off the screen during calls, developers find more creative uses. The Glimmer app uses the proximity sensor to skip tracks with a hand wave in front of the screen — swipe your palm to skip a song. Battery life is unaffected: the sensor consumes only 0.3–0.7 mA.
The main issue with proximity sensors is false triggers when using screen protectors and cases. Some manufacturers (Google Pixel 8, 2023) use an ultrasonic proximity sensor instead of IR — it works through any screen protectors and displays of any thickness but has lower accuracy and higher latency (up to 100 ms). Thick glass (over 0.5 mm) scatters IR radiation, causing constant triggering. The solution is to use cases with a precise cutout for the sensor. A second drawback is the inability to work through OLED displays with variable transparency (under-display sensor).
In 2024–2025, manufacturers began implementing under-display proximity sensors, reducing the top bezel to 1–2 mm. The first mass-produced device with an under-display proximity sensor was the Xiaomi 14 Ultra (2024), followed by the OnePlus 12 and Samsung Galaxy S25. The technology uses IR radiation at 940 nm, which partially passes through OLED pixels. According to Samsung Display Technical Paper (2024), OLED transparency for IR radiation is 15–25% — sufficient for the sensor to operate at screen brightness up to 600 cd/m². At higher brightness, the matrix becomes opaque to IR, requiring the backlight to be turned off for 1–2 frames for measurement.
When developing Android apps, the emulator does not support the proximity sensor — it must be emulated in software. On a physical device, you can use the adb command: adb shell sendevent /dev/input/eventX with the appropriate ABS_MT_TOUCH_MAJOR codes. To simulate screen-off during a call in tests, use SensorManager with a mock object that returns 0 when onSensorChanged is called.
To test the proximity sensor on an Android device, open the Phone app, dial *#0*# (on Samsung), and select Sensor. When you bring your finger close to the top of the screen, the sensor value should change from “Far” to “Near.” If the sensor does not respond, clean the top of the screen and check for a screen protector covering the sensor. On iPhone, testing is done through system diagnostics in Settings.
Frequently Asked Questions
The most common cause is a screen protector or case covering the proximity sensor. Make sure the area near the earpiece is not blocked. If the problem occurs on a bare phone, it may be a hardware defect or a dirty sensor.
The sensor is located at the top of the front panel, next to the earpiece speaker. In modern smartphones, it is hidden under the display glass. You can see it by shining a bright flashlight at an angle — it looks like a small dot or slit.
With standard Android tools — no. However, there are apps that access the engineering menu (dial *#0*# on Samsung) for testing. On some devices, sensitivity can be adjusted through service mode.
The standard proximity sensor API returns only a detection flag — 0 or maxRange. For precise distance, use a Time-of-Flight sensor (if the device has one) — available through the same TYPE_PROXIMITY on compatible devices.
It depends on the thickness and material. Thin flexible protectors (0.15–0.2 mm) do not affect operation. Thick tempered glass (0.5+ mm) can scatter IR radiation and cause false triggering. Protectors with a precise cutout or a black frame around the sensor are recommended.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also