I want develop a video player app, when the device is landscape, the video is full screen playing, when device is portrait the video is half-screen playig. In the landscape, there is a button, when user click it, app will force to portrait(At this moment, the devie still horizontal. What I want: When user change the device to vertical, and change device to horizontal again, the app can auto change from portrait to landscape.
I call the setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
to force to portrait. After I call setRequestedOrientation()
,onConfigurationChanged()
will NOT call again when I change the device from horizontal to vertical. So there is no time point to call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR)
.
I try the OrientationEventListener
, but in onOrientationChanged()
there is a lot of value will return back. But what I want just the device Orientation(landscape or portrait).
Is there any other method to do what I want simply?