I am facing the problem while retrieving the contacts from the contact book in Android 8.0 Oreo java.lang.IllegalStateException: Only fullscreen opaque activities can reques
I recently faced the issue and here's the solution.
No need to change the screen orientation parameter which you set at android manifest file.
Just add two folders in
res>values
as res>values-v26
and res>values-v27
Then copy your styles.xml and themes.xml file there.
and change the following parameters from TRUE to FALSE.
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsTranslucent">false</item>
It will work.
A common bug of Android 8.0
The only thing that worked for me was changing
android:screenOrientation="portrait"
to
android:screenOrientation="unspecified"
in the manifest for all translucent activities.
That way it is compatible with all API versions since the translucent activity seems to inherit its orientation from the parent activity as of targetApi: 28
.
The style can be left as it is including <item name="android:windowIsTranslucent">true</item>
.
In Android O and later this error happens when you set
android:screenOrientation="portrait"
in Manifest.
Remove that line and use
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
in your activity.
This will fix your issue.
If you have to use setRequestedOrientation()
, there is no way but sacrifice the windowIsTranslucent attribute on Android 8.0
values\styles.xml
for api level 25- (<8.0)
<style name="Base.Theme.DesignDemo" parent="Base.Theme.AppCompat.Light">
...
<item name="android:windowIsTranslucent">true</item>
...
</style>
values-v26\styles.xml
for api level 26 (=8.0)
<style name="Base.Theme.DesignDemo" parent="Base.Theme.AppCompat.Light">
...
<!-- android 8.0(api26),Only fullscreen opaque activities can request orientation -->
<item name="android:windowIsTranslucent">false</item>
...
</style>
values-v27\styles.xml
for api level 27+ (>8.0)
<style name="Base.Theme.DesignDemo" parent="Base.Theme.AppCompat.Light">
...
<item name="android:windowIsTranslucent">true</item>
...
</style>
I had the same problem, and my solution was to eliminate the line
android:screenOrientation="portrait"
and then add this in the activity:
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
only 8.0.0 throw the exception, above 8.0 has remove the exception