wonday / react-native-orientation-locker

A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RN 0.58 + Android target SDK 27 = Problem with orientation locker

radeno opened this issue · comments

Hi,

its looks like that Android by SDK 27 and up change ability to locking screen which are not fullscreen.
It is only issue when target SDK is set to 27, which is default in RN 0.58. But when is compiled with target SDK 26 it works.
Error:
Issue: java.lang.IllegalStateException: Only fullscreen activities can request orientation

Any hints how to fix it without any complex solution ? Maybe add oneliner into AndroidManifest.xml ?

Same issues in different repositories
Instabug/Instabug-Android#68
ParkSangGwon/TedPermission#63

I have digging down and this is problem just with RN 0.58 branch. Because combination target SDK 27 and ReactActivity extending from Activity.

RN 0.59 extending from AppCompatActivity which will fix it.
More about issue in this link: https://stackoverflow.com/questions/49124073/how-to-restrict-screen-orientation-to-portrait-in-android-sdk-27

Simple working fix is disabling translucent feature
in file android/app/src/main/res/values/styles.xml replace:

<item name="android:windowIsTranslucent">true</item>

to

<item name="android:windowIsTranslucent">false</item>

Maybe this can be noticed in Readme file.

It is bug just for Android 8.0.

I had add this notice to readme.

Im having the same issue with RN 0.59.0 and SDK 28

I don't think that the version of react-native matters, I get the error also with RN 0.61.5 on android 8. I'll try @radeno solution.

Android 8 is the problem here.

The problem with @radeno solution is that it breaks the https://github.com/crazycodeboy/react-native-splash-screen that requires <item name="android:windowIsTranslucent">true</item> to be nice and smooth.

By making this fix, your splashscreen will have a white flash instead of being nice and smooth.

I'll test a couple of solutions from this thread and see if I can get something to work for android 8 with splashscreen.

https://stackoverflow.com/questions/48072438/java-lang-illegalstateexception-only-fullscreen-opaque-activities-can-request-o