This question is to get more clarification. I have seen this question and there is a lot of answers in it, but there are many and all differ slightly.
Yesterday I updated my app and suddenly got a lot of crashes saying:
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2858)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2933)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1612)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
In the question mentioned above, people suggested that you should either:
- change
<item name="android:windowIsTranslucent">true</item>to<item name="android:windowIsTranslucent">false</item> - change
android:screenOrientation="portrait"tosetRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - or remove
android:screenOrientation="portrait"
In my case I have an Activity and I have set the theme in styles like this:
<style name="Theme.Transparent" parent="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>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
and in my manifest:
<activity android:name=".camView"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/Theme.Transparent">.......//some metadata
My question:
Is it safe to say that changing <item name="android:windowIsTranslucent">true</item> to <item name="android:windowIsTranslucent">false</item> and keeping android:screenOrientation="landscape" in my manifest, will resolve this issue?
Why is this happening?
I think it might be worth mentioning that I have added the following in my Activity onCreate, just before setContentView(R.layout.activity_cam_view); (I'm not sure if this will affect anything):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE;
getWindow().setAttributes(layout);
}