question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[android] Orientation.unlockAllOrientations () does not work

See original GitHub issue

I’m using react-navigation, In the previous screen, I used lockToPortrait () to prevent landscape.

In the next screen, I was working on unlockAllOrientations () to make the landscape change possible.

But unlockAllOrientations () does not work on Android! The addDeviceOrientationListener obviously changes, but the UI does not change.

Is there a way to solve it? I need help

The problem only occurs with Android. iOS works fine.

lock landscape screen

componentDidMount = () => {
    this.getFeedData();
    setTimeout(() => {
      Orientation.lockToPortrait();
    }, 10);
  };

I was going to go to the next screen and unlock it using unlockAllOrientations ().

unlock screen

componentDidMount = () => {
    BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
    Orientation.addDeviceOrientationListener(this.onOrientationDidChange);
    Orientation.unlockAllOrientations();
  }

android version

buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"

I run it with version 8.1 Android emulator. react-native-orientation-locker, use 1.1.1 version now

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
junhoKimscommented, Jan 24, 2019

found!

In styles.xml on Android <item name = "android: windowIsTranslucent"> true </ item>

If you comment out this, it works perfectly on Android.

0reactions
Balakumar777commented, Sep 11, 2019

Hi guys I am using react-native camera for barCode scan. When componentMount I lock the device orientation into Landscape. When componentWillUnmount I used unlockAllOrientations. But the device remains the Landscape only in IOS. In android it works fine. Anyway to fix this in IOS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Orientation does not listening Current System ...
Im using react-native-orientation . I want to lock initial login screen in portrait mode. so i have used Orientation.lockToPortrait() in app.tsx ...
Read more >
react-native-orientation-locker - npm
A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
Read more >
42-react-native-orientation-locker - NPM Package Overview
A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
Read more >
Set or Get Preferred Device Orientation in React Native
Hello guys, This is an Example to Get Device Orientation and Set Preferred Orientation ... Open node_modules/react-native-orientation/android/build.gradle.
Read more >
Fixing orientation problems on react-native ... - MitrahSoft Blog
Solution For ReactNative Barcode Scanning Mobile App Orientation Problems ... natively rendering mobile applications for iOS and Android.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found