florisdh commented on issue #75: URL: https://github.com/apache/cordova-plugin-screen-orientation/issues/75#issuecomment-713072580
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](https://github.com/florisdh/capacitor-orientation-bug/commit/b16a1602559138cf5051cb1321b08ffdfe90e047) You can run my [demo project](https://github.com/florisdh/capacitor-orientation-bug) 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](https://github.com/florisdh/capacitor-orientation-bug/commit/b16a1602559138cf5051cb1321b08ffdfe90e047) 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](https://github.com/florisdh/cordova-plugin-screen-orientation/commit/8f99ca366a9adee948242b630586d4e2fe733d52). 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! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
