gpt4 book ai didi

android - Activity 在强制关闭时重新启动

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:59:06 25 4
gpt4 key购买 nike

我有一个只有一个根 Activity 的应用程序。我最近注意到我的 Activity 上的任何强制关闭都会导致它重新启动,我不知道为什么会发生这种情况。如果我强制一个未捕获的异常或使用“长按后退强制关闭”选项,它们都会产生相同的结果。

我唯一的猜测是某种形式的与保留对 Activity 某些部分的引用有关的怪癖,只是我在应用程序级别没有任何弱引用条目之外的任何内容。

相关的 logcat 条目:

05-25 08:25:49.137: INFO/ActivityManager(18449): Displayed uk.co.randomicon.rstb/.TreeBuilderActivity: +8s82ms
05-25 08:25:54.222: DEBUG/dalvikvm(18546): GC_EXPLICIT freed 12K, 57% free 3640K/8327K, external 8323K/10136K, paused 72ms
05-25 08:25:55.373: WARN/InputManagerService(18449): Got RemoteException sending setActive(false) notification to pid 19122 uid 10069
05-25 08:25:59.217: DEBUG/dalvikvm(18646): GC_EXPLICIT freed 128K, 48% free 2980K/5703K, external 0K/0K, paused 67ms
05-25 08:26:00.238: DEBUG/dalvikvm(18991): GC_CONCURRENT freed 343K, 51% free 2794K/5639K, external 303K/532K, paused 3ms+3ms
05-25 08:26:02.950: INFO/Process(18449): Sending signal. PID: 19554 SIG: 9
05-25 08:26:02.980: INFO/ActivityManager(18449): Process uk.co.randomicon.rstb (pid 19554) has died.
05-25 08:26:02.990: ERROR/InputDispatcher(18449): channel '40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
05-25 08:26:02.990: ERROR/InputDispatcher(18449): channel '40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
05-25 08:26:02.990: INFO/WindowManager(18449): WINDOW DIED Window{40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity paused=false}
05-25 08:26:03.010: WARN/WindowManager(18449): Failed looking up window
05-25 08:26:03.010: WARN/WindowManager(18449): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@40c774e0 does not exist
05-25 08:26:03.010: WARN/WindowManager(18449): at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8177)
05-25 08:26:03.010: WARN/WindowManager(18449): at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8168)
05-25 08:26:03.010: WARN/WindowManager(18449): at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:7026)
05-25 08:26:03.010: WARN/WindowManager(18449): at android.os.BinderProxy.sendDeathNotice(Binder.java:385)
05-25 08:26:03.010: WARN/WindowManager(18449): at dalvik.system.NativeStart.run(Native Method)
05-25 08:26:03.010: INFO/WindowManager(18449): WIN DEATH: null
05-25 08:26:03.020: INFO/ActivityManager(18449): Start proc uk.co.randomicon.rstb for activity uk.co.randomicon.rstb/.TreeBuilderActivity: pid=19565 uid=10069 gids={1015}

任何从哪里开始戳戳的想法都将不胜感激!

编辑:这是因为我在我的 list 中设置了 android:stateNotNeeded="true"。虽然我不需要状态,但这导致 Android 决定最好重新启动我的应用程序,假设用户会想要它。

最佳答案

Here是一些有用的信息:

As far as when an activity is restarted -- if the process running the foreground activity goes away, the system will throw away that activity if it does not have a valid saved state for it (typically meaning it is paused and has given the system the result of onSaveInstanceState from before the pause). Once it has decided whether or not to throw away that activity, it will resume whatever activity is now at the top of the stack. If this is one of your activities -- either because you have another behind the one that crashed, or the one that crashed was somehow it the settled pause state -- then it will start your process again to show that top activity.

关于android - Activity 在强制关闭时重新启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6121300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com