heinrichreimer / material-intro

A simple material design app intro with cool animations and a fluent API.
https://jitpack.io/#com.heinrichreimer/material-intro
MIT License
1.74k stars 308 forks source link

Only fullscreen opaque activities can request orientation #278

Open kelalaka153 opened 4 years ago

kelalaka153 commented 4 years ago

When the application call's the Welcome class that extends IntroActivity on version 1.6

I've got an error

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xyz/com/xyz.firsttime.Welcome}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

The Application Manifest is

    <application
            android:allowBackup="false"
            android:icon="@mipmap/app_icon_white_blue"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/app_icon_white_blue_round"
            android:screenOrientation="portrait"
            android:supportsRtl="true"
            android:hardwareAccelerated="true"
            android:theme="@style/AppTheme"

and Welcome Activity in Manifest

        <activity
                android:name="com.xyz.firsttime.Welcome"
                android:theme="@style/Theme.Intro"
                android:screenOrientation="portrait"
                >
        </activity>

I've got this error only on Android one device with version Android 8.

How to resolve this issue?

heinrichreimer commented 4 years ago

Please post the full stack trace and corresponding code in your Activity class, so that we can understand the problem. Note though, that material-intro does not need orientation to be locked, and that all standard slide styles come with landscape layouts too.

kelalaka153 commented 4 years ago

I'm using portrait mode in all of the activities. Material Intro version 1.6

also;

    <style name="Theme.Intro" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>

Process: com.xyz, PID: 21337 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xyz/com.xyz.firsttime.Welcome}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2820) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6565) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation at android.app.Activity.onCreate(Activity.java:986) at androidx.core.app.e.onCreate(Unknown Source:0) at androidx.activity.ComponentActivity.onCreate(Unknown Source:0) at androidx.fragment.app.d.onCreate(Unknown Source:99) at androidx.appcompat.app.e.onCreate(Unknown Source:10) at c.c.a.k.a.onCreate(Unknown Source:0) at com.xyz.firsttime.Welcome.onCreate(Unknown Source:2) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2773) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6565)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

heinrichreimer commented 4 years ago

There is a bug in Android 8 (SDK 26), that prevents activities from locking screen duration if <item name="android:windowIsTranslucent">true</item> is set in the activity's style. The material-intro library uses that flag for the fade-out effect while swiping away the last slide. As far as I know, the only solution would be to either disable window translucency for API 26 devices, or to not lock orientation while the intro is visible. @chimbori would you like to investigate this issue?

kelalaka153 commented 4 years ago

Easiest is disabling the orientation and it worked. How can I disable window translucency only for API 26 devices?

would you like to investigate this issue? Sure