[SOLVED] Screen Orientation is locked on portrait Android but works fine on iOS

Hello,

I have a - maybe silly - question:

Ionic Capacitor App: on iOS if I rotate the device, the screen rotates - and that’s the behaviour i’m expecting.

On Android, even if I rotate the device, the screen is locked on portrait: I tried to check the AndroidManifest.xml but I can’t see anything related to screen rotation.

Do you know what can I check?

If it works on iOS it should work on Android too or do I need the screen orientation plugin, because it is an Android wanted behaviour?

Thank you!

[SOLVED]

I just had to add 1 line in my AndroidManifest.xml as explained here:

android:screenOrientation
The orientation of the activity's display on the device. The system ignores this attribute if the activity is running in multi-window mode.
The value can be any one of the following strings:

"unspecified"	The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
"behind"	The same orientation as the activity that's immediately beneath it in the activity stack.
"landscape"	Landscape orientation (the display is wider than it is tall).
"portrait"	Portrait orientation (the display is taller than it is wide).
"reverseLandscape"	Landscape orientation in the opposite direction from normal landscape. Added in API level 9.
"reversePortrait"	Portrait orientation in the opposite direction from normal portrait. Added in API level 9.
"sensorLandscape"	Landscape orientation, but can be either normal or reverse landscape based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. Added in API level 9.
"sensorPortrait"	Portrait orientation, but can be either normal or reverse portrait based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. Added in API level 9.
"userLandscape"	Landscape orientation, but can be either normal or reverse landscape based on the device sensor and the user's preference. Added in API level 18.
"userPortrait"	Portrait orientation, but can be either normal or reverse portrait based on the device sensor and the user's preference. Added in API level 18.
"sensor"	The orientation is determined by the device orientation sensor. The orientation of the display depends on how the user is holding the device; it changes when the user rotates the device. Some devices, though, will not rotate to all four possible orientations, by default. To allow all four orientations, use "fullSensor" The sensor is used even if the user locked sensor-based rotation.
"fullSensor"	The orientation is determined by the device orientation sensor for any of the 4 orientations. This is similar to "sensor" except this allows any of the 4 possible screen orientations, regardless of what the device will normally do (for example, some devices won't normally use reverse portrait or reverse landscape, but this enables those). Added in API level 9.
"nosensor"	The orientation is determined without reference to a physical orientation sensor. The sensor is ignored, so the display will not rotate based on how the user moves the device.
"user"	The user's current preferred orientation.
"fullUser"	If the user has locked sensor-based rotation, this behaves the same as user, otherwise it behaves the same as fullSensor and allows any of the 4 possible screen orientations. Added in API level 18.
"locked"	Locks the orientation to its current rotation, whatever that is. Added in API level 18.
1 Like