Typically, a 90-degree rotating device (portrait or landscape) causes a configuration change, activity is destroyed and restored, etc., so it can simply save the value Display.getRotation()at startup and work with it.
However, when the device is rotated directly from 0 to 180 (portrait portrait) or from 90 to 270 (landscape to landscape), the configuration is not changed, the device simply reassigns the screen. This makes sense because the aspect ratio of the layout does not change and does not need to be changed. But this makes it impossible for the Activity to detect when such changes occur, i.e. When Surface.ROTATION_90moved to Surface.ROTATION_270, etc.
Besides polling Display.getRotation(), is there a better way to detect this change?
source
share