Open florisdh opened 4 years ago
Sorry, clicked the wrong button. Can you elaborate what's the difference in your fix and why it works again as expected?
From the android docs
Sensor:
Orientation is determined by a physical orientation sensor: the display will rotate based on how the user moves the device. Ignores user's setting to turn off sensor-based rotation.
Unspecified:
No preference specified: let the system decide the best orientation. This will either be the orientation selected by the activity below, or the user's preferred orientation if this activity is the bottom of a task. If the user explicitly turned off sensor based orientation through settings sensor based device rotation will be ignored. If not by default sensor based orientation will be taken into account and the orientation will changed based on how the user rotates the device.
It sounds like if we used sensor
it may cause the app to ignore user settings, which sounds like a bad assumption to make.
Hey guys, thanks for the quick reply. 🤘
In the end I decided to create a demo project showing the issue that we're facing. After some hours of debugging why our project actually has this behaviour, I found what was causing this weird behaviour here
You can run my demo project and see that running screen.orientation.unlock() will cause the screen to lock to portrait for some reason.
This is probably caused by the underlaying activity somehow being locked to portrait by this and the unspecified option used by this plugin will use this as seen in the docs
Unspecified: ... This will either be the orientation selected by the activity below, or ...
Aside from this my 'fix' was using Sensor as breautek mentioned, which is also not really ideal since it would ignore the user settings, so I changed it to use the 'ActivityInfo.SCREEN_ORIENTATION_USER' as seen here. This will only use the sensor if enabled.
As a developer I would expect that calling screen.orientation.unlock() would actually unlock the screen orientation by using the sensor if enabled in the settings, thus I think it would be best to change it to ActivityInfo.SCREEN_ORIENTATION_USER.
Anyway our issue is fixed, so I rest my case.
Thanks for the support!
In my case, .lock("landscape") doesn't work. It either still uses the setting from the config.xml or, if you used .unlock() first, the phone will still use all orientations instead of just "landscape".
Bug Report
Problem
Since a few weeks we noticed that the orientation suddenly didn't allow unlocking anymore in our app.
What is expected to happen?
After calling unlock(), the app should use the sensor for the right orientation.
What does actually happen?
When calling unlock(), it was going back to forced portrait.
Environment, Platform, Device
Tried on multiple android devices.
Version information
I've made a fix which we are using now, which can be found here.