Search code examples
androidandroid-sensorsproximitysensor

Is it possible to change the maximum range on the Android proximity sensor?


Can I use the proximity sensor to detect something further than the maximum range returned by sensor.getMaximumRange()? Something like 50cm instead of the 8cm I'm getting now?


Solution

  • I don't think so. Usually the proximity sensor give back 0 or max range because this is usually used to turn the screen off when you call and your head is near the phone.

    Note: Some proximity sensors only support a binary near or far measurement. In this case, the sensor should report its maximum range value in the far state and a lesser value in the near state.

    After it really depends of the hardware of the phone but I doubt that you can outranged the maxRange value. You can still take a look on aosp about the sensor stack but the native fragment is close to what android.hardware is.