yamill / react-native-orientation

Listen to device orientation changes in react-native and set preferred orientation on screen to screen basis.
https://www.npmjs.com/package/react-native-orientation
ISC License
1.72k stars 810 forks source link

Android | unlockAllOrientations uses the device sensor instead of user preference #274

Open jmasseydp opened 6 years ago

jmasseydp commented 6 years ago

Tested on the latest version of Android (8.1.0) on a Google Pixel

When the device is portrait locked, calling unlockAllOrientations uses the device sensor for rotation instead of the user preference, causing the activity to rotate freely even though the user has preferred otherwise. Here is the code:

@ReactMethod public void unlockAllOrientations() { final Activity activity = getCurrentActivity(); if (activity == null) { return; } activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }

Using SCREEN_ORIENTATION_USER instead of sensor seems to alleviate the issue, but is there a particular reason that sensor is being used instead?

ntnamag commented 6 years ago

Same problem. It's uncomfortable