Is the Android proximity sensor delay controlled?

Asked 2 years ago, Updated 2 years ago, 126 views

I have a question because there is something that doesn't work well while studying Android.

 mSensorManager= (SensorManager)getSystemService(Context).SENSOR_SERVICE );
  mSensor = mSensorManager.getDefaultSensor( Sensor.TYPE_PROXIMITY );
  mSensorManager.registerListener(this, mSensor,SensorManager.SENSOR_DELAY_FASTEST);

I declared that I would use a proximity sensor like this.

And I followed the higher declaration because the third argument of registerListener is to determine the delay.

switch (rate) {
            case SENSOR_DELAY_FASTEST:
                delay = 0;
                break;
            case SENSOR_DELAY_GAME:
                delay = 20000;
                break;
            case SENSOR_DELAY_UI:
                delay = 66667;
                break;
            case SENSOR_DELAY_NORMAL:
                delay = 200000;
                break;
            default:
                delay = rate;
                break;
        }

These codes were found.

Default allows the user to give delay.

However, no matter how much I test it, I don't think there's a difference in the proximity sensor.

I want to get it once every three seconds. Isn't there a way to solve it with that factor other than the thread?

application android proximity-sensor

2022-09-22 19:43

1 Answers

The application stage cannot directly control the sampling period of the sensor. I think it can only be controlled at the driver and kernel level.

It is thought that these parameters are used to suggest that the system requires a sampling period of this application.

This context can also be seen in the Guide document for that method. https://developer.android.com/reference/android/hardware/SensorManager.html#registerListener(android.hardware.SensorEventListener,%20android.hardware.Sensor,%20int)


2022-09-22 19:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.