react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

unlockAllOrientations is not working for Android

Open elmcapp opened this issue 2 years ago • 2 comments

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.

elmcapp avatar Mar 21 '22 11:03 elmcapp

Have you added the following to MainApplication.java

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

hexadecy avatar Mar 30 '22 18:03 hexadecy

Have you added the following to MainApplication.java

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

yes

elmcapp avatar Mar 30 '22 21:03 elmcapp