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 used android:screenOrientation="behind"
instead of android:screenOrientation="portrait"
. Basically, you created a dialog (in an activity) and dialog can't request orientation by itself it needs parent activity to do this (because a parent is visible in the background and has own layout).
"behind" The same orientation as the activity that's immediately beneath it in the activity stack.
in the manifest file set second activity parentActivityName as first activity and remove the screenOrientation parameter to the second activity. it means your first activity is the parent and decide to an orientation of your second activity.
<activity
android:name=".view.FirstActiviy"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".view.SecondActivity"
android:parentActivityName=".view.FirstActiviy"
android:theme="@style/AppTheme.Transparent" />
If you haven't resolved your problem just register the ad activity in the manifest like this:
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
tools:replace="android:theme"
/>
You also need to update to the latest version of the sdk.
I can't agree to most rated answer, because
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
causes an error
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
but this makes it works for me
<style name="TranslucentTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
and use it for your Activity, when you extends from
InterstitialActivity extends AppCompatActivity
in AndroidManifest.xml
<activity
android:name=".InterstitialActivity"
...
android:screenOrientation="portrait"
android:theme="@style/TranslucentTheme" />
this happened after 27,use targetSdkVersion 26 replace, wait for google fixed it
It is a conflict (bug) between Themes inside style.xml file in android versions 7 (Api levels 24,25) & 8 (api levels 26,27), when you have
android:screenOrientation="portrait"
:inside specific activity (that crashes) in AndroidManifest.xml
&
<item name="android:windowIsTranslucent">true</item>
in the theme that applied to that activity inside style.xml
It can be solve by these ways according to your need :
1- Remove on of the above mentioned properties that make conflict
2- Change Activity orientation to one of these values as you need : unspecified
or behind
and so on that can be found here : Google reference for android:screenOrientation
`
3- Set the orientation programmatically in run time