Turn off light sensor during a call - Android

When you talk on the phone in Android, the light sensor works. If you close the upper left corner of the screen, the display turns black and you see nothing.

I would like to cancel this function, and I tried working with Android sensors and Light Sensor , but it does not work.

This is my code:

 senMgrLight=(SensorManager)getSystemService(Context.SENSOR_SERVICE);
    senMgrLight.registerListener(onSensorListener,
            senMgrLight.getDefaultSensor(Sensor.TYPE_LIGHT),
                SensorManager.SENSOR_DELAY_FASTEST);

Thank.

+3
source share
4 answers

The sensor you need to work with is the proximity sensor, try this, it will let you know if the sensor is hidden or not (and it works during your call)

   SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
        sm.registerListener(new SensorEventListener() {

            @Override
            public void onSensorChanged(SensorEvent event) {
                Log.i(TAG,"sensor: " + event.sensor.getName() + ", values: " + Arrays.toString(event.values));

            }

            @Override
            public void onAccuracyChanged(Sensor sensor, int accuracy) {
                Log.i(TAG,"accuracy change: " + sensor + ", accuracy: " + accuracy);

            }
        }, sm.getDefaultSensor(Sensor.TYPE_PROXIMITY),SensorManager.SENSOR_DELAY_FASTEST);
+2
source

Settings.System, SCREEN_BRIGHTNESS SCREEN_BRIGHTNESS_MODE getInt() . setInt(), 255 SCREEN_BRIGHTNESS_MODE_MANUAL - .

, , , , setInt(), .: -)

, Android 2.2 ( API 8), , Android. , , .

+1

, . ""

+1
source

I bet you will like this app! PROXIMITY-SENSOR-OFF.apk

Regards
CVS @ 2600Hertz

0
source

Source: https://habr.com/ru/post/1776474/


All Articles