Alf*_*tch 5 android transparent lockscreen android-lifecycle android-activity
我正在经历这 <item name="android:windowIsTranslucent">true</item>正在改变 Android Lifecycle 的处理方式。我想这样做是因为如果窗口是半透明的,您仍然可以看到底层活动。我们称之为活动 A。
让我们看一下下面的示例,其中我们在活动 A 之上有另一个活动。这个其他活动称为 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.
Run Code Online (Sandbox Code Playgroud)
让我们看看另一个场景,其中 windowIsTranslucent 为活动 B 设置为 true。
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)
Run Code Online (Sandbox Code Playgroud)
你们中的任何人都知道为什么会抛出这个问题吗?任何修复 - 或者我可以在不使用 windowIsTranslucent 的情况下使活动透明吗?
| 归档时间: |
|
| 查看次数: |
589 次 |
| 最近记录: |