androidandroid-layoutandroid-mediaplayerandroid-sensorsandroid-orientation

Android OrientationEventListener SensorManager.SENSOR_DELAY_NORMAL Necessity


From the documentation, which says:

Use the default value of SENSOR_DELAY_NORMAL for simple screen orientation change detection.

Does it mean that if I don't include the sensor rate in the constructor, it will still apply the SENSOR_DELAY_NORMAL?

In other words, are this two the same:

OrientationEventListener(context)

OrientationEventListener(context, Sensor.SENSOR_DELAY_NORMAL)

PS: I use for simple screen orientation change detection.


Solution

  • According to the official source code, the former constructor is defined as follows,

    /**
     * Creates a new OrientationEventListener.
     * 
     * @param context for the OrientationEventListener.
     */
    public OrientationEventListener(Context context) {
        this(context, SensorManager.SENSOR_DELAY_NORMAL);
    }
    

    So, it's completely equivalent to the latter. You can use whichever you like.