ParkSangGwon / TedPermission

Easy check permission library for Android Marshmallow
1.74k stars 238 forks source link

Only fullscreen opaque activities can request orientation #63

Closed NunciosChums closed 6 years ago

NunciosChums commented 6 years ago

version: tedpermission-rx2:2.0.3 phone: emulator Nexus 5X 26, 27

java.lang.RuntimeException: Unable to start activity ComponentInfo{kr.my/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
   at android.app.ActivityThread.-wrap11(Unknown Source:0)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
   at android.os.Handler.dispatchMessage(Handler.java:106)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6494)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
   at android.app.Activity.onCreate(Activity.java:987)
   at android.support.v4.app.SupportActivity.onCreate(SupportActivity.java:66)
   at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:297)
   at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84)
   at com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:64)
   at android.app.Activity.performCreate(Activity.java:7000)
   at android.app.Activity.performCreate(Activity.java:6991)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
   at android.app.ActivityThread.-wrap11(Unknown Source:0) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
   at android.os.Handler.dispatchMessage(Handler.java:106) 
   at android.os.Looper.loop(Looper.java:164) 
   at android.app.ActivityThread.main(ActivityThread.java:6494) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
GrayaMax commented 6 years ago

I had the same issue, the only fix i found for now is to use android support library 26.1.0. Its seems to be a problem with android library 27.0.0.

JSpiner commented 6 years ago

@GrayaMax can you tell me more information?

GrayaMax commented 6 years ago

@JSpiner sorry I don't have more information, i realized i get this error when i upgraded appcompat-v7 to version 27.0.0. So for now i return to version 26.1.0 and it still working. I will post more information if I find more.

ParkSangGwon commented 6 years ago

@susemi99 @GrayaMax @JSpiner There are some problem. After 27( Android O), If we use android:screenOrientation="portrait" in manifest, we got error like that. If I remove that, we can solve. But I dont think that is real solution. I want to reason and try to real solution.

socialvanana commented 6 years ago

For Android developers, Recommend to use targetSdkVersion as 26 instead of 27 for a while.

andreas- commented 6 years ago

Fix that worked for us targetSdkVersion 27

and add TedPermissionActivity to your manifest where you override android:screenOrientation <activity android:name="com.gun0912.tedpermission.TedPermissionActivity" android:configChanges="mcc|mnc|locale|keyboard|keyboardHidden|screenLayout|fontScale|uiMode|orientation|screenSize|layoutDirection" android:screenOrientation="unspecified" android:theme="@style/Theme.Transparent.Permission" tools:replace="android:screenOrientation"/>

bbincybbaby commented 6 years ago

?? can you explain it in more detail?

BoxResin commented 6 years ago

@andreas- Great. It works!

JSpiner commented 6 years ago

@ParkSangGwon According to this commit. Since android 'O'(26), we should satisfy following condition.

if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
                 && appInfo.targetSdkVersion >= O) {
             throw new IllegalStateException("Only fullscreen activities can request orientation");
         }

I think some of these solutions are possible.

  1. Enable fullscreen

    • Because the TedPermissionActivity is transparent. It doesn't matter.
  2. Set screenOrientation as unspecified

    • Same with @andreas- solution.
    • We don't know which direction the application using this library will use. So we should support all direction.
  3. Customize

    • add setScreenOrientation() function at PermissionBuilder
  4. Trick Code

    • First, enable fullscreen mode.
    • Set orientation as unspecified.
    • Reset fullscreen mode.
    • Done!

Give me your opinion. I'll make PR.

andreas- commented 6 years ago

@JSpiner i'd suggest to go with option 2 We experienced wonky behavior when dealing with fullscreen activities and immersive mode. This library should not make assumptions about the orientation

@BoxResin glad i could help

JSpiner commented 6 years ago

@andreas- I totally agree with you! Also, I think it should support option 3.

add setScreenOrientation() function at PermissionBuilder

So I'll make PR using 1/3 option.

ParkSangGwon commented 6 years ago

This issue solved at 842b86f And I will publish new version. Thanks all guys

minsik-ai commented 6 years ago

Please update new version with this issue, thank you.

LivioGama commented 6 years ago

+1

alexodus commented 6 years ago

+1

juice77 commented 6 years ago

+1

melodysdreamj commented 6 years ago

+1

VOstopolets commented 6 years ago

+1

milad-mr commented 6 years ago

1+

hamidraasti commented 6 years ago

+1

NicolasKun commented 6 years ago

same problem. thanks for the explain 👍

roman-ku commented 6 years ago

I'm still getting this problem. Was the fix pushed?

fajaranugrah commented 5 years ago

how to create only android:screenOrientation="portrait" ? can you help me

jughoor commented 4 years ago

The problem is fixed in version gun0912.ted:tedpermission:2.2.0 but if you use gun0912.ted:tedpermission:2.2.2 with target version 28 the App will crash.