Unless the developer of an application has it blocked to work only in portrait mode (usually by adding the «portrait» property on the line android: screenOrientation in the main activity in the file manifest.xml) the application will turn in the direction of the device, horizontally or vertically, when automatic rotation is activated. This is especially annoying when lying down using your mobile phone, and portrait mode (portrait mode in English) is always preferred, for example for YouTube or Netflix videos.
You can’t control the app code, but you can change your Android settings to keep the screen vertical at any time and in any app. You simply need to display the notification panel and switch the automatic mode to the vertical mode or go to System settings, the Screen option.
Disable automatic rotation
When you swipe down on the status bar at the top, you’ll see a panel with several shortcuts, including screen orientation. If it’s in automatic mode, you simply need to tap it to turn it off and leave vertical mode on.
Also from Settings, Display
You need to open the Android settings (drag the top bar and tap the gear) and select the «Show» menu. In the list of options there must be one on screen flip, from which you can select the mode «Keep the view vertical«.
Unfortunately, some devices do not display this option in the settings, as in the case of my Huawei Y5 with Android 9.
Applications so that the screen does not rotate
As we have seen, it is not normally necessary to install applications to keep the screen vertical on Android, but if for some reason they are necessary, this article details some of the best applications for this task, such as SetOrientation or Rotation control (available for free in Play Store), which in addition to being used to activate portrait mode (Portrait), are essential when you want to lock the screen in landscape mode, which in many devices can not be done in the mode shown above (In some devices it is apparently possible to lock the screen in the current orientation mode, be it portrait or landscape).
How to force a landscape or portrait orientation on Android
How to rotate rotate your mobile phone screen (manually or automatically)
How to increase the screen time