wonday / react-native-orientation-locker

A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
MIT License
752 stars 273 forks source link

unlockAllOrientations is not working for Android #220

Open elmcapp opened 2 years ago

elmcapp commented 2 years ago

unlockAllOrientations function is not unlocking the orientations on Android devices.

Scenario 1: If you rotate your device to landscape then you call lockToLandscape() the device will stay on landscape even if you rotate it back to portrait view and that is the expected behavior. However if you call unlockAllOrientations() then you rotate the device to portrait view it will stay in landscape view

Scenario 2: If your device is in portrait view and you call lockToLandscape() the view will automatically rotate to landscape even if the device is being held in portrait mode. This is the expected behavior however if you call unlockAllOrientations() the device will stay stuck in landscape no matter how you hold the device. You can rotate your device to portrait then landscape then back to portrait it will stay in landscape.

Once you lock the orientation to portrait or landscape you can call unlockAllOrientations() however the device view will stay at the view in which you locked it too. And this problem remain no matter if you rotate the device. Basically its is as if unlockAllOrientations() function does not work at all on Android. iOS works great but Android it does not work.

hexadecy commented 2 years ago

Have you added the following to MainApplication.java

+import org.wonday.orientation.OrientationActivityLifecycle;
  @Override
  public void onCreate() {
+    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
  }
elmcapp commented 2 years ago

Have you added the following to MainApplication.java

+import org.wonday.orientation.OrientationActivityLifecycle;
  @Override
  public void onCreate() {
+    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance());
  }

yes