I have a single activity app. Most of the time screen must be in portrait orientation unless it shows video in full screen (I`m expecting to use ExoPlayer). So if I lock the orientation in manifest how can I rotate activity or player view itself?
Asked
Active
Viewed 3,369 times
1 Answers
1
Programmatically you can change orientation by:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Just put it in a onClick event or whatever you desire.

Will
- 413
- 6
- 23
-
if you are in a fragment, we may need to call getActivity() first. ex:- getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); – charitha amarasinghe Oct 08 '21 at 18:24