08-29 16:46:32.282 17040-17040/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.demo.androidAppdemo, PID: 17040
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo.androidAppdemo/com.example.demo.androidAppdemo.Modules.FireBase.NotificationActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.Activity.onCreate(Activity.java:1081)
at android.support.v4.app.SupportActivity.onCreate(SupportActivity.java:66)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:321)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84)
at com.example.demo.androidAppdemo.BaseActivity.onCreate(BaseActivity.java:93)
at com.example.demo.androidAppdemo.Modules.FireBase.NotificationActivity.onCreate(NotificationActivity.java:87)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
android.app.ActivityThread.main (ActivityThread.java:7425)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
I used MainActivity to list notifications in Fragment and if a notification is clicked then the full screen transparent NotificationActivity opens with image and detail. I found crash on Android Oreo Honor device while opening NotificaionActivity. Process: com.example.demo.androidAppdemo, PID: 17040
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo.androidAppdemo/com.example.demo.androidAppdemo.Modules.FireBase.NotificationActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.Activity.onCreate(Activity.java:1081)
at android.support.v4.app.SupportActivity.onCreate(SupportActivity.java:66)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:321)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84)
at com.example.demo.androidAppdemo.BaseActivity.onCreate(BaseActivity.java:93)
at com.example.demo.androidAppdemo.Modules.FireBase.NotificationActivity.onCreate(NotificationActivity.java:87)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
android.app.ActivityThread.main (ActivityThread.java:7425)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppThemeHome"/>
<activity
<activity
android:name=".Modules.NotificationActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Translucent"/>
Also, setting screen-orientation parameter programmatically in transparent activity not worked. android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppThemeHome"/>
<activity
<activity
android:name=".Modules.NotificationActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Translucent"/>
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
if an Activity is fullscreen translucent activity. there is no need to set the screen orientation lock. Screen orientation of translucent or floating activity is relied on background Activity().You Need to make changes to your AndroidManifest.xml file
Either set the screen-orientation parameter of the NotificationActivity to "unspecified" or remove the screen-orientation parameter then it worked for me. Application not crashing and Transparent Activity(NotificationActivity) maintaining the portrait mode despite the auto-rotate on all devices (I have tested this on HTC(Android-4.3.4), Mi note 3 (Android-M) and Honour device(Android 8.0)).
android:name=".Modules.NotificationActivity"
android:screenOrientation="unspecified"
android:theme="@style/Theme.AppCompat.Translucent"/>