windowIsTranslucent changes lifecycle, but error occur when entering lock screen

a 夏天 提交于 2019-12-06 10:19:14

问题


I'm experiencing that <item name="android:windowIsTranslucent">true</item> is changing the way Android Lifecycle is handled. I guess it's doing that because if the window is translucent, you can still see the underlaying activity. Let's call it activity A.

Let's go through the following example where we have another activity on top of activity A. This other activity is called B.

Activity A Started - This activity is the first activity
Activity A Stopped - Now you start activity B.
Activity B Started - This activity has windowIsTranslucent set to false. Hence we can't see anything of activity A anymore which is why activity A stopped.
Now hit the power button to go into lockscreen mode. 
Activity B Stopped - Since none is visible anymore activity B also stops. 

Let's look on another scenario where windowIsTranslucent is set to true for activity B.

Activity A Started - This activity is the first activity
Activity A Paused - Now you start activity B.
Activity B Started - This activity has windowIsTranslucent true (we want to see through it so it's still possible to see activity A)
Now hit the power button to go into lockscreen mode. 
Activity B Paused
Activity B Stopped
Activity A Stopped
Everything looks fine expect a RuntimeException is thrown that for me makes no sense since it's not stopped before?

E/ActivityThread: Performing stop of activity that is already stopped: {testapp/ActivityA}
java.lang.RuntimeException: Performing stop of activity that is already stopped: {testapp/ActivityA}
    at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3996)
    at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4084)
    at android.app.ActivityThread.-wrap24(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1622)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Any of you have any ideas why this is thrown? Any fix - or can i make an activity transparent without using windowIsTranslucent?

来源:https://stackoverflow.com/questions/51536494/windowistranslucent-changes-lifecycle-but-error-occur-when-entering-lock-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!