Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test proximity sensor in Samsung galaxy S10 or S10+?

Tags:

java

android

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();
   }

like image 383
Zohaib ZJ Avatar asked Apr 04 '19 08:04

Zohaib ZJ


People also ask

Does Samsung S10 have proximity sensor?

The Samsung Galaxy S10 5G features an Infinity O display that minimizes the bezel, so the proximity sensor is now located at the top of the display.

How do I know if my proximity sensor is working?

One way to test your sensor is by simply placing your phone near your face to see if it lights up. Another way to do so is to request a call and place your phone near your ear to see if it picks up. If these don't work, you can download a free third-party app like Sensor Test to see if it's working.


1 Answers

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

like image 82
MobMob Avatar answered Oct 10 '22 03:10

MobMob