【问题标题】:Android OrientationEventListener SensorManager.SENSOR_DELAY_NORMAL NecessityAndroid OrientationEventListener SensorManager.SENSOR_DELAY_NORMAL 必要性
【发布时间】:2021-04-14 21:46:33
【问题描述】:
来自documentation,上面写着:
使用 SENSOR_DELAY_NORMAL 的默认值进行简单的屏幕方向变化检测。
是否意味着如果我在构造函数中不包含传感器速率,它仍然会应用SENSOR_DELAY_NORMAL?
也就是说,这两个是一样的吗:
OrientationEventListener(context)
OrientationEventListener(context, Sensor.SENSOR_DELAY_NORMAL)
PS:我用于简单的屏幕方向变化检测。
【问题讨论】:
标签:
android
android-layout
android-mediaplayer
android-sensors
android-orientation
【解决方案1】:
根据the official source code,前面的构造函数定义如下,
/**
* Creates a new OrientationEventListener.
*
* @param context for the OrientationEventListener.
*/
public OrientationEventListener(Context context) {
this(context, SensorManager.SENSOR_DELAY_NORMAL);
}
所以,它完全等同于后者。你可以使用任何你喜欢的。