问题描述
来自 documentation,它说:
使用默认值 SENSOR_DELAY_NORMAL 进行简单的屏幕方向变化检测。
这是否意味着如果我不在构造函数中包含传感器速率,它仍然会应用SENSOR_DELAY_NORMAL
?
换句话说,这两个是否相同:
OrientationEventListener(context)
OrientationEventListener(context,Sensor.SENSOR_DELAY_NORMAL)
PS:我用于简单的屏幕方向变化检测。
解决方法
根据the official source code,前面的构造函数定义如下,
/**
* Creates a new OrientationEventListener.
*
* @param context for the OrientationEventListener.
*/
public OrientationEventListener(Context context) {
this(context,SensorManager.SENSOR_DELAY_NORMAL);
}
所以,完全等同于后者。你可以随意使用。