I want to test proximity sensor on Samsung newer model (s10 or s10+), I have used the old conventional way to register the listener for the proximity sensor and it is working for all the device except these 2 ones. I have searched over the internet and come to know that S10 has proximity sensor under the display (a blinking pixel lights up during call etc). I have also used many 3rd party sensor testing apps but none of them is working for S10. Does anyone know what Samsung has changed? how we can access S10 proximity sensor programmatically? I have tried the below code but it is always toasting far.

@Override
   public void onSensorChanged(SensorEvent event) {
       if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) {
           if (event.values[0] >= -SENSOR_SENSITIVITY && event.values[0] <= SENSOR_SENSITIVITY) {
               //near
               Toast.makeText(getApplicationContext(), "near", Toast.LENGTH_SHORT).show();
           } else {
               //far
               Toast.makeText(getApplicationContext(), "far", Toast.LENGTH_SHORT).show();
           }
       }
   }

   @Override
   public void onAccuracyChanged(Sensor sensor, int accuracy) {
       Toast.makeText(getApplicationContext(), "accuracy changed", Toast.LENGTH_SHORT).show();
   }

2 Answers

0
Community On

In simple terms(non-programatically) Method1 star hash zero star hash(#0#)on dialer A block of options will be there(red,green,blue,vibration,camera)in that select proximity sensor.now it will show the lux(luminious intensity)amount more light more lux.check that wise also.also u can hover now the display appears green with a vibration. Method2 Do a call.During the call the right top area (left side of camera)a white dot will be blinking in the display itself.(looks like a pixel dot).now hover and check.

1
Community On

You can use secret code *#77692# Test proximity sensor on Samsung Galaxy S10