I managed to change the orientation for my fragment in my activity. Orientation changes when my device is rotated.
Now I want to use the same functionality when I click a button in a snippet. that is, I want to switch from portrait mode to LandScape mode when I press the button on the portrait layout and vera visa.
I used
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
and
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
respectively.
But this led to the fact that the automatic rotation function stopped working. How can I fix this problem?
source share