PictureSelector icon indicating copy to clipboard operation
PictureSelector copied to clipboard

Android 8.0 Only fullscreen opaque activities can request orientation

Open mastergyp opened this issue 8 years ago • 11 comments

target_sdk 27 时候调用时出错.应该样式问题, maven里可否修改? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.xxx.vp, PID: 12863 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.vp/com.luck.picture.lib.PictureSelectorActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6545) 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 android.support.v4.app.SupportActivity.onCreate(SupportActivity.java:66) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:297) at com.luck.picture.lib.PictureBaseActivity.onCreate(PictureBaseActivity.java:67) at com.luck.picture.lib.PictureSelectorActivity.onCreate(PictureSelectorActivity.java:140) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6545)  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)  01-15 02:21:46.811 25104-25104/com.vapeam.vp E/AccountInfoTools: getAppid is 0

mastergyp avatar Jan 15 '18 09:01 mastergyp

Same here! java.lang.RuntimeException: Unable to start activity ComponentInfo{*/com.luck.picture.lib.PictureSelectorActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

raza-elahi avatar Jan 15 '18 09:01 raza-elahi

我也遇到相同的问题 java.lang.RuntimeException:Unable to start activity ComponentInfo{*/com.luck.picture.lib.PictureSelectorActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

jiangqingbo avatar Jan 18 '18 09:01 jiangqingbo

@rkaram-sadad I try to import picture_library into my project as module and i modify his styles.xml from <item name="android:windowIsTranslucent">true</item> into <item name="android:windowIsTranslucent">false</item> and it works well.

mastergyp avatar Jan 18 '18 10:01 mastergyp

望作者尽快解决8.0的这个报错,修改方式见上

guangzq avatar Jan 22 '18 05:01 guangzq

Set Orientation of activity in Manifiest.xml android:screenOrientation="unspecified"

imattaullah avatar Aug 25 '18 18:08 imattaullah

@mastergyp then what is the replacement of <item name="android:windowIsTranslucent">true</item> I need this lines of code.

AhmadullahSaikat avatar Sep 25 '18 12:09 AhmadullahSaikat

I faced this problem only in SDK 26 (8.0.0) if using windowIsTranslucent 'true' and forcefully setting orientation:

Here's the solution:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
	

	// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
    if (Build.VERSION.SDK_INT == 26) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }        
}



   <style name="SplashActivty" parent="AppTheme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
</style>

hamzaahmedkhan avatar Sep 28 '18 07:09 hamzaahmedkhan

I faced this problem only in SDK 26 (8.0.0) if using windowIsTranslucent 'true' and forcefully setting orientation:

Here's the solution:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
	

	// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
    if (Build.VERSION.SDK_INT == 26) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }        
}



   <style name="SplashActivty" parent="AppTheme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
</style>

This does not work, the error occurs when the super.onCreate() is called.

I suggest just remove the orientation script in the manifest.

AlexCJW avatar Nov 20 '18 09:11 AlexCJW

I faced this problem only in SDK 26 (8.0.0) if using windowIsTranslucent 'true' and forcefully setting orientation: Here's the solution:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
	

	// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
    if (Build.VERSION.SDK_INT == 26) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }        
}



   <style name="SplashActivty" parent="AppTheme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
</style>

This does not work, the error occurs when the super.onCreate() is called.

I suggest just remove the orientation script in the manifest.

Set Orientation of activity in Manifiest.xml android:screenOrientation="unspecified"

imattaullah avatar Nov 21 '18 13:11 imattaullah

I resolved this issue by removing android:screenOrientation="portrait" and added below code into my onCreate

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

while my theme properties are

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

WaheedNazir avatar Feb 24 '20 03:02 WaheedNazir

I have the same issue but is didn't used windowistransulet = true in my theme

rakesh4075 avatar May 02 '20 08:05 rakesh4075