一、OrientationEventListener 和 OrientationListener
1、 OrientationEventListener
Helper class for receiving notifications from the SensorManager when the orientation of the device has changed.
方法:
boolean canDetectOrientation()
:判断是否支持旋转
void
disable()
Disables the OrientationEventListener.
void
enable()
Enables the OrientationEventListener so it will monitor the sensor and call onOrientationChanged(int) when the device orientation changes.
abstract void
onOrientationChanged(int orientation)
Called when the orientation of the device has changed.
2、OrientationListener
过时,android4.0以后不再使用
二、 Android 应用横竖屏切换,不受系统横竖屏切换控制的代码。
在AndroidManifast.xml 相关的Activity 里面添加。
android:screenOrientation="sensor"
android:configChanges="orientation|screenSize|keyboardHidden"
代码里面,重新方法:onConfigurationChanged